time-to-botec

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

README.md (3954B)


      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 > [Triangular][triangular-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 [triangular][triangular-distribution] random variable with lower limit `a`, upper limit `b`, and mode `c` is
     30 
     31 <!-- <equation class="equation" label="eq:triangular_mode" align="center" raw="\operatorname{mode}\left( X \right) = c" alt="Mode for a triangular distribution."> -->
     32 
     33 <div class="equation" align="center" data-raw-text="\operatorname{mode}\left( X \right) = c" data-equation="eq:triangular_mode">
     34     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/triangular/mode/docs/img/equation_triangular_mode.svg" alt="Mode for a triangular 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/triangular/mode' );
     52 ```
     53 
     54 #### mode( a, b, c )
     55 
     56 Returns the [mode][mode] of a [triangular][triangular-distribution] distribution with parameters `a` (minimum support), `b` (maximum support), and `c` (mode).
     57 
     58 ```javascript
     59 var v = mode( 0.0, 1.0, 0.8 );
     60 // returns 0.8
     61 
     62 v = mode( 4.0, 12.0, 5.0 );
     63 // returns 5.0
     64 
     65 v = mode( 2.0, 8.0, 5.0 );
     66 // returns 5.0
     67 ```
     68 
     69 If provided `NaN` as any argument, the function returns `NaN`.
     70 
     71 ```javascript
     72 var v = mode( NaN, 4.0, 2.0 );
     73 // returns NaN
     74 
     75 v = mode( 0.0, NaN, 2.0 );
     76 // returns NaN
     77 
     78 v = mode( 0.0, 4.0, NaN );
     79 // returns NaN
     80 ```
     81 
     82 If provided parameters not satisfying `a <= c <= b`, the function returns `NaN`.
     83 
     84 ```javascript
     85 var y = mode( 1.0, 0.0, 1.5 );
     86 // returns NaN
     87 
     88 y = mode( 0.0, 1.0, -1.0 );
     89 // returns NaN
     90 
     91 y = mode( 0.0, -1.0, 0.5 );
     92 // returns NaN
     93 ```
     94 
     95 </section>
     96 
     97 <!-- /.usage -->
     98 
     99 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    100 
    101 <section class="notes">
    102 
    103 </section>
    104 
    105 <!-- /.notes -->
    106 
    107 <!-- Package usage examples. -->
    108 
    109 <section class="examples">
    110 
    111 ## Examples
    112 
    113 <!-- eslint no-undef: "error" -->
    114 
    115 ```javascript
    116 var randu = require( '@stdlib/random/base/randu' );
    117 var mode = require( '@stdlib/stats/base/dists/triangular/mode' );
    118 
    119 var a;
    120 var b;
    121 var c;
    122 var v;
    123 var i;
    124 
    125 for ( i = 0; i < 10; i++ ) {
    126     a = ( randu()*10.0 );
    127     b = ( randu()*10.0 ) + a;
    128     c = ( randu()*( b-a ) ) + a;
    129     v = mode( a, b, c );
    130     console.log( 'a: %d, b: %d, c: %d, mode(X;a,b,c): %d', a.toFixed( 4 ), b.toFixed( 4 ), c.toFixed( 4 ), v.toFixed( 4 ) );
    131 }
    132 ```
    133 
    134 </section>
    135 
    136 <!-- /.examples -->
    137 
    138 <!-- 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. -->
    139 
    140 <section class="references">
    141 
    142 </section>
    143 
    144 <!-- /.references -->
    145 
    146 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    147 
    148 <section class="links">
    149 
    150 [triangular-distribution]: https://en.wikipedia.org/wiki/Triangular_distribution
    151 
    152 [mode]: https://en.wikipedia.org/wiki/Mode_%28statistics%29
    153 
    154 </section>
    155 
    156 <!-- /.links -->