README.md (3519B)
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 > [Rayleigh][rayleigh-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 [Rayleigh][rayleigh-distribution] random variable is 30 31 <!-- <equation class="equation" label="eq:rayleigh_median" align="center" raw="\operatorname{Median}\left( X \right) = \sigma \sqrt{2 \ln(2)}" alt="Median for a Rayleigh distribution."> --> 32 33 <div class="equation" align="center" data-raw-text="\operatorname{Median}\left( X \right) = \sigma \sqrt{2 \ln(2)}" data-equation="eq:rayleigh_median"> 34 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/rayleigh/median/docs/img/equation_rayleigh_median.svg" alt="Median for a Rayleigh distribution."> 35 <br> 36 </div> 37 38 <!-- </equation> --> 39 40 where `σ > 0` is the scale parameter. 41 42 </section> 43 44 <!-- /.intro --> 45 46 <!-- Package usage documentation. --> 47 48 <section class="usage"> 49 50 ## Usage 51 52 ```javascript 53 var median = require( '@stdlib/stats/base/dists/rayleigh/median' ); 54 ``` 55 56 #### median( sigma ) 57 58 Returns the [median][median] of a [Rayleigh][rayleigh-distribution] distribution with scale 59 parameter `sigma`. 60 61 ```javascript 62 var y = median( 9.0 ); 63 // returns ~10.597 64 65 y = median( 1.5 ); 66 // returns ~1.766 67 ``` 68 69 If provided `sigma < 0`, the function returns `NaN`. 70 71 ```javascript 72 var y = median( -1.0 ); 73 // returns NaN 74 ``` 75 76 </section> 77 78 <!-- /.usage --> 79 80 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 81 82 <section class="notes"> 83 84 </section> 85 86 <!-- /.notes --> 87 88 <!-- Package usage examples. --> 89 90 <section class="examples"> 91 92 ## Examples 93 94 <!-- eslint no-undef: "error" --> 95 96 <!-- eslint no-undef: "error" --> 97 98 ```javascript 99 var randu = require( '@stdlib/random/base/randu' ); 100 var round = require( '@stdlib/math/base/special/round' ); 101 var median = require( '@stdlib/stats/base/dists/rayleigh/median' ); 102 103 var sigma; 104 var y; 105 var i; 106 107 for ( i = 0; i < 10; i++ ) { 108 sigma = randu() * 20.0; 109 y = median( sigma ); 110 console.log( 'σ: %d, Median(X,σ): %d', sigma.toFixed( 4 ), y.toFixed( 4 ) ); 111 } 112 ``` 113 114 </section> 115 116 <!-- /.examples --> 117 118 <!-- 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. --> 119 120 <section class="references"> 121 122 </section> 123 124 <!-- /.references --> 125 126 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 127 128 <section class="links"> 129 130 [rayleigh-distribution]: https://en.wikipedia.org/wiki/Rayleigh_distribution 131 132 [median]: https://en.wikipedia.org/wiki/Median 133 134 </section> 135 136 <!-- /.links -->