|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2026 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 | +> [Log-logistic][log-logistic-distribution] 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 [log-logistic][log-logistic-distribution] random variable with scale `α > 0` and shape `β > 1` is |
| 30 | + |
| 31 | +<!-- <equation class="equation" label="eq:log-logistic_mode" align="center" raw="\mathop{\mathrm{mode}}\left( X \right) = \alpha \left( \frac{\beta - 1}{\beta + 1} \right)^{1/\beta}" alt="Mode for a log-logistic distribution."> --> |
| 32 | + |
| 33 | +```math |
| 34 | +\mathop{\mathrm{mode}}\left( X \right) = \alpha \left( \frac{\beta - 1}{\beta + 1} \right)^{1/\beta} |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- <div class="equation" align="center" data-raw-text="\mathop{\mathrm{mode}}\left( X \right) = \alpha \left( \frac{\beta - 1}{\beta + 1} \right)^{1/\beta}" data-equation="eq:log-logistic_mode"> |
| 38 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/log-logistic/mode/docs/img/equation_log_logistic_mode.svg" alt="Mode for a log-logistic distribution."> |
| 39 | + <br> |
| 40 | +</div> --> |
| 41 | + |
| 42 | +<!-- </equation> --> |
| 43 | + |
| 44 | +</section> |
| 45 | + |
| 46 | +<!-- /.intro --> |
| 47 | + |
| 48 | +<!-- Package usage documentation. --> |
| 49 | + |
| 50 | +<section class="usage"> |
| 51 | + |
| 52 | +## Usage |
| 53 | + |
| 54 | +```javascript |
| 55 | +var mode = require( '@stdlib/stats/base/dists/log-logistic/mode' ); |
| 56 | +``` |
| 57 | + |
| 58 | +#### mode( alpha, beta ) |
| 59 | + |
| 60 | +Returns the [mode][mode] for a [log-logistic][log-logistic-distribution] distribution with scale parameter `alpha` and shape parameter `beta`. |
| 61 | + |
| 62 | +```javascript |
| 63 | +var y = mode( 1.0, 2.0 ); |
| 64 | +// returns ~0.577 |
| 65 | + |
| 66 | +y = mode( 4.0, 3.0 ); |
| 67 | +// returns ~3.175 |
| 68 | +``` |
| 69 | + |
| 70 | +If provided `NaN` as any argument, the function returns `NaN`. |
| 71 | + |
| 72 | +```javascript |
| 73 | +var y = mode( NaN, 2.0 ); |
| 74 | +// returns NaN |
| 75 | + |
| 76 | +y = mode( 2.0, NaN ); |
| 77 | +// returns NaN |
| 78 | +``` |
| 79 | + |
| 80 | +If provided `alpha <= 0`, the function returns `NaN`. |
| 81 | + |
| 82 | +```javascript |
| 83 | +var y = mode( 0.0, 2.0 ); |
| 84 | +// returns NaN |
| 85 | + |
| 86 | +y = mode( -1.0, 2.0 ); |
| 87 | +// returns NaN |
| 88 | +``` |
| 89 | + |
| 90 | +If provided `beta <= 0`, the function returns `NaN`. |
| 91 | + |
| 92 | +```javascript |
| 93 | +var y = mode( 2.0, 0.0 ); |
| 94 | +// returns NaN |
| 95 | + |
| 96 | +y = mode( 2.0, -1.0 ); |
| 97 | +// returns NaN |
| 98 | +``` |
| 99 | + |
| 100 | +</section> |
| 101 | + |
| 102 | +<!-- /.usage --> |
| 103 | + |
| 104 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 105 | + |
| 106 | +<section class="notes"> |
| 107 | + |
| 108 | +</section> |
| 109 | + |
| 110 | +<!-- /.notes --> |
| 111 | + |
| 112 | +<!-- Package usage examples. --> |
| 113 | + |
| 114 | +<section class="examples"> |
| 115 | + |
| 116 | +## Examples |
| 117 | + |
| 118 | +<!-- eslint no-undef: "error" --> |
| 119 | + |
| 120 | +```javascript |
| 121 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 122 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 123 | +var mode = require( '@stdlib/stats/base/dists/log-logistic/mode' ); |
| 124 | + |
| 125 | +var opts = { |
| 126 | + 'dtype': 'float64' |
| 127 | +}; |
| 128 | +var alpha = uniform( 10, 0.1, 10.0, opts ); |
| 129 | +var beta = uniform( 10, 1.1, 10.0, opts ); |
| 130 | + |
| 131 | +logEachMap( 'alpha: %0.4f, beta: %0.4f, Mode(X;alpha,beta): %0.4f', alpha, beta, mode ); |
| 132 | +``` |
| 133 | + |
| 134 | +</section> |
| 135 | + |
| 136 | +<!-- /.examples --> |
| 137 | + |
| 138 | +<!-- C interface documentation. --> |
| 139 | + |
| 140 | +* * * |
| 141 | + |
| 142 | +<section class="c"> |
| 143 | + |
| 144 | +## C APIs |
| 145 | + |
| 146 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 147 | + |
| 148 | +<section class="intro"> |
| 149 | + |
| 150 | +</section> |
| 151 | + |
| 152 | +<!-- /.intro --> |
| 153 | + |
| 154 | +<!-- C usage documentation. --> |
| 155 | + |
| 156 | +<section class="usage"> |
| 157 | + |
| 158 | +### Usage |
| 159 | + |
| 160 | +```c |
| 161 | +#include "stdlib/stats/base/dists/log-logistic/mode.h" |
| 162 | +``` |
| 163 | + |
| 164 | +#### stdlib_base_dists_log_logistic_mode( alpha, beta ) |
| 165 | + |
| 166 | +Returns the mode for a log-logistic distribution with scale `alpha` and shape `beta`. |
| 167 | + |
| 168 | +```c |
| 169 | +double out = stdlib_base_dists_log_logistic_mode( 1.0, 2.0 ); |
| 170 | +// returns ~0.577 |
| 171 | +``` |
| 172 | + |
| 173 | +The function accepts the following arguments: |
| 174 | + |
| 175 | +- **alpha**: `[in] double` scale parameter. |
| 176 | +- **beta**: `[in] double` shape parameter. |
| 177 | + |
| 178 | +```c |
| 179 | +double stdlib_base_dists_log_logistic_mode( const double alpha, const double beta ); |
| 180 | +``` |
| 181 | +
|
| 182 | +</section> |
| 183 | +
|
| 184 | +<!-- /.usage --> |
| 185 | +
|
| 186 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 187 | +
|
| 188 | +<section class="notes"> |
| 189 | +
|
| 190 | +</section> |
| 191 | +
|
| 192 | +<!-- /.notes --> |
| 193 | +
|
| 194 | +<!-- C API usage examples. --> |
| 195 | +
|
| 196 | +<section class="examples"> |
| 197 | +
|
| 198 | +### Examples |
| 199 | +
|
| 200 | +```c |
| 201 | +#include "stdlib/stats/base/dists/log-logistic/mode.h" |
| 202 | +#include <stdlib.h> |
| 203 | +#include <stdio.h> |
| 204 | +
|
| 205 | +static double random_uniform( const double min, const double max ) { |
| 206 | + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); |
| 207 | + return min + ( v*(max-min) ); |
| 208 | +} |
| 209 | +
|
| 210 | +int main( void ) { |
| 211 | + double alpha; |
| 212 | + double beta; |
| 213 | + double v; |
| 214 | + int i; |
| 215 | +
|
| 216 | + for ( i = 0; i < 25; i++ ) { |
| 217 | + alpha = random_uniform( 0.1, 10.0 ); |
| 218 | + beta = random_uniform( 1.1, 10.0 ); |
| 219 | + v = stdlib_base_dists_log_logistic_mode( alpha, beta ); |
| 220 | + printf( "alpha: %lf, beta: %lf, Mode(X;alpha,beta): %lf\n", alpha, beta, v ); |
| 221 | + } |
| 222 | +} |
| 223 | +``` |
| 224 | + |
| 225 | +</section> |
| 226 | + |
| 227 | +<!-- /.examples --> |
| 228 | + |
| 229 | +</section> |
| 230 | + |
| 231 | +<!-- /.c --> |
| 232 | + |
| 233 | +<!-- 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. --> |
| 234 | + |
| 235 | +<section class="references"> |
| 236 | + |
| 237 | +</section> |
| 238 | + |
| 239 | +<!-- /.references --> |
| 240 | + |
| 241 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 242 | + |
| 243 | +<section class="related"> |
| 244 | + |
| 245 | +</section> |
| 246 | + |
| 247 | +<!-- /.related --> |
| 248 | + |
| 249 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 250 | + |
| 251 | +<section class="links"> |
| 252 | + |
| 253 | +[log-logistic-distribution]: https://en.wikipedia.org/wiki/Log-logistic_distribution |
| 254 | + |
| 255 | +[mode]: https://en.wikipedia.org/wiki/Mode |
| 256 | + |
| 257 | +</section> |
| 258 | + |
| 259 | +<!-- /.links --> |
0 commit comments