|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# Mode |
| 22 | + |
| 23 | +> Planck (discrete exponential) distribution [mode][mode]. |
| 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 [mode][mode] for a Planck random variable with shape parameter `λ` is |
| 30 | + |
| 31 | +<!-- <equation class="equation" label="eq:planck_mode" align="center" raw="\operatorname{mode}\left( X \right) = 0" alt="Mode for a Planck distribution."> --> |
| 32 | + |
| 33 | +```math |
| 34 | +\mathop{\mathrm{mode}}\left( X \right) = 0 |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- </equation> --> |
| 38 | + |
| 39 | +</section> |
| 40 | + |
| 41 | +<!-- /.intro --> |
| 42 | + |
| 43 | +<!-- Package usage documentation. --> |
| 44 | + |
| 45 | +<section class="usage"> |
| 46 | + |
| 47 | +## Usage |
| 48 | + |
| 49 | +```javascript |
| 50 | +var mode = require( '@stdlib/stats/base/dists/planck/mode' ); |
| 51 | +``` |
| 52 | + |
| 53 | +#### mode( lambda ) |
| 54 | + |
| 55 | +Returns the [mode][mode] of a Planck distribution with shape parameter `lambda`. |
| 56 | + |
| 57 | +```javascript |
| 58 | +var v = mode( 0.1 ); |
| 59 | +// returns 0 |
| 60 | + |
| 61 | +v = mode( 1.5 ); |
| 62 | +// returns 0 |
| 63 | +``` |
| 64 | + |
| 65 | +If provided a shape parameter `lambda` is nonpositive or `NaN`, the function returns `NaN`. |
| 66 | + |
| 67 | +```javascript |
| 68 | +var v = mode( NaN ); |
| 69 | +// returns NaN |
| 70 | + |
| 71 | +v = mode( -1.5 ); |
| 72 | +// returns NaN |
| 73 | +``` |
| 74 | + |
| 75 | +</section> |
| 76 | + |
| 77 | +<!-- /.usage --> |
| 78 | + |
| 79 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 80 | + |
| 81 | +<section class="notes"> |
| 82 | + |
| 83 | +</section> |
| 84 | + |
| 85 | +<!-- /.notes --> |
| 86 | + |
| 87 | +<!-- Package usage examples. --> |
| 88 | + |
| 89 | +<section class="examples"> |
| 90 | + |
| 91 | +## Examples |
| 92 | + |
| 93 | +<!-- eslint no-undef: "error" --> |
| 94 | + |
| 95 | +```javascript |
| 96 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 97 | +var mode = require( '@stdlib/stats/base/dists/planck/mode' ); |
| 98 | + |
| 99 | +var lambda = uniform( 10, 0.1, 5.0 ); |
| 100 | + |
| 101 | +var v; |
| 102 | +var i; |
| 103 | +for ( i = 0; i < lambda.length; i++ ) { |
| 104 | + v = mode( lambda[ i ] ); |
| 105 | + console.log( 'λ: %d, mode(X;λ): %d', lambda[ i ].toFixed( 4 ), v.toFixed( 4 ) ); |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +</section> |
| 110 | + |
| 111 | +<!-- /.examples --> |
| 112 | + |
| 113 | +<!-- 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. --> |
| 114 | + |
| 115 | +<section class="references"> |
| 116 | + |
| 117 | +</section> |
| 118 | + |
| 119 | +<!-- /.references --> |
| 120 | + |
| 121 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 122 | + |
| 123 | +<section class="related"> |
| 124 | + |
| 125 | +</section> |
| 126 | + |
| 127 | +<!-- /.related --> |
| 128 | + |
| 129 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 130 | + |
| 131 | +<section class="links"> |
| 132 | + |
| 133 | +[mode]: https://en.wikipedia.org/wiki/Mode_%28statistics%29 |
| 134 | + |
| 135 | +</section> |
| 136 | + |
| 137 | +<!-- /.links --> |
0 commit comments