README.md (4198B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Median 22 23 > [Fréchet][frechet-distribution] distribution [median][median]. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 The [median][median] for a [Fréchet][frechet-distribution] random variable shape `α > 0`, scale `s > 0`, and location parameter `m` is 30 31 <!-- <equation class="equation" label="eq:frechet_median" align="center" raw="\operatorname{Median} = m+{\frac {s}{{\sqrt[ {\alpha }]{\ln(2)}}}}" alt="Median for a Fréchet distribution."> --> 32 33 <div class="equation" align="center" data-raw-text="\operatorname{Median} = m+{\frac {s}{{\sqrt[ {\alpha }]{\ln(2)}}}}" data-equation="eq:frechet_median"> 34 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/frechet/median/docs/img/equation_frechet_median.svg" alt="Median for a Fréchet distribution."> 35 <br> 36 </div> 37 38 <!-- </equation> --> 39 40 </section> 41 42 <!-- /.intro --> 43 44 <!-- Package usage documentation. --> 45 46 <section class="usage"> 47 48 ## Usage 49 50 ```javascript 51 var median = require( '@stdlib/stats/base/dists/frechet/median' ); 52 ``` 53 54 #### median( alpha, s, m ) 55 56 Returns the [median][median] for a [Fréchet][frechet-distribution] distribution with shape `alpha > 0`, scale `s > 0`, and location parameter `m`. 57 58 ```javascript 59 var y = median( 2.0, 1.0, 1.0 ); 60 // returns ~2.201 61 62 y = median( 1.0, 2.0, -3.0 ); 63 // returns ~-0.115 64 65 y = median( 1.0, 1.0, 2.0 ); 66 // returns ~3.443 67 ``` 68 69 If provided `NaN` as any argument, the function returns `NaN`. 70 71 ```javascript 72 var y = median( NaN, 1.0, -2.0 ); 73 // returns NaN 74 75 y = median( 1.0, NaN, -2.0 ); 76 // returns NaN 77 78 y = median( 1.0, 1.0, NaN ); 79 // returns NaN 80 ``` 81 82 If provided `alpha <= 0`, the function returns `NaN`. 83 84 ```javascript 85 var y = median( 0.0, 3.0, 2.0 ); 86 // returns NaN 87 88 y = median( 0.0, -1.0, 2.0 ); 89 // returns NaN 90 ``` 91 92 If provided `s <= 0`, the function returns `NaN`. 93 94 ```javascript 95 var y = median( 1.0, 0.0, 2.0 ); 96 // returns NaN 97 98 y = median( 1.0, -1.0, 2.0 ); 99 // returns NaN 100 ``` 101 102 </section> 103 104 <!-- /.usage --> 105 106 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 107 108 <section class="notes"> 109 110 </section> 111 112 <!-- /.notes --> 113 114 <!-- Package usage examples. --> 115 116 <section class="examples"> 117 118 ## Examples 119 120 <!-- eslint no-undef: "error" --> 121 122 ```javascript 123 var randu = require( '@stdlib/random/base/randu' ); 124 var EPS = require( '@stdlib/constants/float64/eps' ); 125 var median = require( '@stdlib/stats/base/dists/frechet/median' ); 126 127 var alpha; 128 var m; 129 var s; 130 var y; 131 var i; 132 133 for ( i = 0; i < 10; i++ ) { 134 alpha = ( randu()*20.0 ) + EPS; 135 s = ( randu()*20.0 ) + EPS; 136 m = ( randu()*20.0 ) - 40.0; 137 y = median( alpha, s, m ); 138 console.log( 'α: %d, s: %d, m: %d, Median(X;α,s,m): %d', alpha.toFixed( 4 ), s.toFixed( 4 ), m.toFixed( 4 ), y.toFixed( 4 ) ); 139 } 140 ``` 141 142 </section> 143 144 <!-- /.examples --> 145 146 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 147 148 <section class="references"> 149 150 </section> 151 152 <!-- /.references --> 153 154 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 155 156 <section class="links"> 157 158 [frechet-distribution]: https://en.wikipedia.org/wiki/Fr%C3%A9chet_distribution 159 160 [median]: https://en.wikipedia.org/wiki/Median 161 162 </section> 163 164 <!-- /.links -->