time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (4369B)


      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 # Mode
     22 
     23 > [Weibull][weibull-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 [Weibull][weibull-distribution] random variable is
     30 
     31 <!-- <equation class="equation" label="eq:weibull_mode" align="center" raw="\operatorname{mode}\left( X \right) = {\displaystyle {\begin{cases}\lambda \left({\frac {k-1}{k}}\right)^{\frac {1}{k}}\,&k>1\\0&k\leq 1\end{cases}}}" alt="Mode for a Weibull distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="\operatorname{mode}\left( X \right) = {\displaystyle {\begin{cases}\lambda \left({\frac {k-1}{k}}\right)^{\frac {1}{k}}\,&amp;k&gt;1\\0&amp;k\leq 1\end{cases}}}" data-equation="eq:weibull_mode">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/weibull/mode/docs/img/equation_weibull_mode.svg" alt="Mode for a Weibull distribution.">
     35     <br>
     36 </div>
     37 
     38 <!-- </equation> -->
     39 
     40 where `λ > 0` is the [shape parameter][shape] and `k > 0` is the [scale parameter][scale].
     41 
     42 </section>
     43 
     44 <!-- /.intro -->
     45 
     46 <!-- Package usage documentation. -->
     47 
     48 <section class="usage">
     49 
     50 ## Usage
     51 
     52 ```javascript
     53 var mode = require( '@stdlib/stats/base/dists/weibull/mode' );
     54 ```
     55 
     56 #### mode( k, lambda )
     57 
     58 Returns the [mode][mode] of a [Weibull][weibull-distribution] distribution with parameters `k` (shape parameter) and `lambda` (scale parameter).
     59 
     60 ```javascript
     61 var v = mode( 4.0, 12.0 );
     62 // returns ~11.167
     63 
     64 v = mode( 8.0, 2.0 );
     65 // returns ~1.967
     66 ```
     67 
     68 If provided `0 < k <= 1`, the function returns `0.0`.
     69 
     70 ```javascript
     71 var v = mode( 1.0, 1.0 );
     72 // returns 0.0
     73 ```
     74 
     75 If provided `NaN` as any argument, the function returns `NaN`.
     76 
     77 ```javascript
     78 var v = mode( NaN, 2.0 );
     79 // returns NaN
     80 
     81 v = mode( 2.0, NaN );
     82 // returns NaN
     83 ```
     84 
     85 If provided `k <= 0`, the function returns `NaN`.
     86 
     87 ```javascript
     88 var v = mode( 0.0, 1.0 );
     89 // returns NaN
     90 
     91 v = mode( -1.0, 1.0 );
     92 // returns NaN
     93 ```
     94 
     95 If provided `lambda <= 0`, the function returns `NaN`.
     96 
     97 ```javascript
     98 var v = mode( 1.0, 0.0 );
     99 // returns NaN
    100 
    101 v = mode( 1.0, -1.0 );
    102 // returns NaN
    103 ```
    104 
    105 </section>
    106 
    107 <!-- /.usage -->
    108 
    109 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    110 
    111 <section class="notes">
    112 
    113 </section>
    114 
    115 <!-- /.notes -->
    116 
    117 <!-- Package usage examples. -->
    118 
    119 <section class="examples">
    120 
    121 ## Examples
    122 
    123 <!-- eslint no-undef: "error" -->
    124 
    125 ```javascript
    126 var randu = require( '@stdlib/random/base/randu' );
    127 var EPS = require( '@stdlib/constants/float64/eps' );
    128 var mode = require( '@stdlib/stats/base/dists/weibull/mode' );
    129 
    130 var lambda;
    131 var k;
    132 var v;
    133 var i;
    134 
    135 for ( i = 0; i < 10; i++ ) {
    136     k = ( randu()*10.0 ) + EPS;
    137     lambda = ( randu()*10.0 ) + EPS;
    138     v = mode( k, lambda );
    139     console.log( 'k: %d, λ: %d, mode(X;k,λ): %d', k.toFixed( 4 ), lambda.toFixed( 4 ), v.toFixed( 4 ) );
    140 }
    141 ```
    142 
    143 </section>
    144 
    145 <!-- /.examples -->
    146 
    147 <!-- 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. -->
    148 
    149 <section class="references">
    150 
    151 </section>
    152 
    153 <!-- /.references -->
    154 
    155 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    156 
    157 <section class="links">
    158 
    159 [weibull-distribution]: https://en.wikipedia.org/wiki/Weibull_distribution
    160 
    161 [mode]: https://en.wikipedia.org/wiki/Mode
    162 
    163 [shape]: https://en.wikipedia.org/wiki/Shape_parameter
    164 
    165 [scale]: https://en.wikipedia.org/wiki/Scale_parameter
    166 
    167 </section>
    168 
    169 <!-- /.links -->