time-to-botec

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

README.md (3468B)


      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 > [Geometric][geometric-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 [geometric][geometric-distribution] random variable with success probability `p` is
     30 
     31 <!-- <equation class="equation" label="eq:geometric_mode" align="center" raw="\operatorname{mode}\left( X \right) = 0" alt="Mode for a geometric distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="\operatorname{mode}\left( X \right) = 0" data-equation="eq:geometric_mode">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/geometric/mode/docs/img/equation_geometric_mode.svg" alt="Mode for a geometric 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 mode = require( '@stdlib/stats/base/dists/geometric/mode' );
     52 ```
     53 
     54 #### mode( p )
     55 
     56 Returns the [mode][mode] of a [geometric][geometric-distribution] distribution with success probability `p`.
     57 
     58 ```javascript
     59 var v = mode( 0.1 );
     60 // returns 0
     61 
     62 v = mode( 0.5 );
     63 // returns 0
     64 ```
     65 
     66 If provided a success probability `p` outside of `[0,1]`, the function returns `NaN`.
     67 
     68 ```javascript
     69 var v = mode( NaN );
     70 // returns NaN
     71 
     72 v = mode( 1.5 );
     73 // returns NaN
     74 
     75 v = mode( -1.0 );
     76 // returns NaN
     77 ```
     78 
     79 </section>
     80 
     81 <!-- /.usage -->
     82 
     83 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     84 
     85 <section class="notes">
     86 
     87 </section>
     88 
     89 <!-- /.notes -->
     90 
     91 <!-- Package usage examples. -->
     92 
     93 <section class="examples">
     94 
     95 ## Examples
     96 
     97 <!-- eslint no-undef: "error" -->
     98 
     99 ```javascript
    100 var randu = require( '@stdlib/random/base/randu' );
    101 var round = require( '@stdlib/math/base/special/round' );
    102 var mode = require( '@stdlib/stats/base/dists/geometric/mode' );
    103 
    104 var v;
    105 var i;
    106 var p;
    107 
    108 for ( i = 0; i < 10; i++ ) {
    109     p = randu();
    110     v = mode( p );
    111     console.log( 'p: %d, mode(X;p): %d', p.toFixed( 4 ), v.toFixed( 4 ) );
    112 }
    113 ```
    114 
    115 </section>
    116 
    117 <!-- /.examples -->
    118 
    119 <!-- 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. -->
    120 
    121 <section class="references">
    122 
    123 </section>
    124 
    125 <!-- /.references -->
    126 
    127 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    128 
    129 <section class="links">
    130 
    131 [geometric-distribution]: https://en.wikipedia.org/wiki/Geometric_distribution
    132 
    133 [mode]: https://en.wikipedia.org/wiki/Mode_%28statistics%29
    134 
    135 </section>
    136 
    137 <!-- /.links -->