time-to-botec

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

README.md (6977B)


      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 # Discrete Uniform
     22 
     23 > Discrete uniform distribution constructor.
     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 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var DiscreteUniform = require( '@stdlib/stats/base/dists/discrete-uniform/ctor' );
     41 ```
     42 
     43 #### DiscreteUniform( \[a, b] )
     44 
     45 Returns a [discrete uniform][discrete-uniform-distribution] distribution object.
     46 
     47 ```javascript
     48 var discreteUniform = new DiscreteUniform();
     49 
     50 var mu = discreteUniform.mean;
     51 // returns 0.5
     52 ```
     53 
     54 By default, `a = 0` and `b = 1`. To create a distribution having a different `a` (minimum support) and `b` (maximum support), provide the corresponding arguments.
     55 
     56 ```javascript
     57 var discreteUniform = new DiscreteUniform( 2, 4 );
     58 
     59 var mu = discreteUniform.mean;
     60 // returns 3.0
     61 ```
     62 
     63 * * *
     64 
     65 ## discreteUniform
     66 
     67 A [discrete uniform][discrete-uniform-distribution] distribution object has the following properties and methods...
     68 
     69 ### Writable Properties
     70 
     71 #### discreteUniform.a
     72 
     73 Minimum support of the distribution. `a` **must** be an integer smaller than or equal to `b`.
     74 
     75 ```javascript
     76 var discreteUniform = new DiscreteUniform( -2, 2 );
     77 
     78 var a = discreteUniform.a;
     79 // returns -2
     80 
     81 discreteUniform.a = 0;
     82 
     83 a = discreteUniform.a;
     84 // returns 0
     85 ```
     86 
     87 #### discreteUniform.b
     88 
     89 Maximum support of the distribution. `b` **must** be an integer larger than or equal to `a`.
     90 
     91 ```javascript
     92 var discreteUniform = new DiscreteUniform( 2, 4 );
     93 
     94 var b = discreteUniform.b;
     95 // returns 4
     96 
     97 discreteUniform.b = 3;
     98 
     99 b = discreteUniform.b;
    100 // returns 3
    101 ```
    102 
    103 * * *
    104 
    105 ### Computed Properties
    106 
    107 #### DiscreteUniform.prototype.entropy
    108 
    109 Returns the [differential entropy][entropy].
    110 
    111 ```javascript
    112 var discreteUniform = new DiscreteUniform( 4, 12 );
    113 
    114 var entropy = discreteUniform.entropy;
    115 // returns ~2.197
    116 ```
    117 
    118 #### DiscreteUniform.prototype.kurtosis
    119 
    120 Returns the [excess kurtosis][kurtosis].
    121 
    122 ```javascript
    123 var discreteUniform = new DiscreteUniform( 4, 12 );
    124 
    125 var kurtosis = discreteUniform.kurtosis;
    126 // returns -1.23
    127 ```
    128 
    129 #### DiscreteUniform.prototype.mean
    130 
    131 Returns the [expected value][expected-value].
    132 
    133 ```javascript
    134 var discreteUniform = new DiscreteUniform( 4, 12 );
    135 
    136 var mu = discreteUniform.mean;
    137 // returns 8.0
    138 ```
    139 
    140 #### DiscreteUniform.prototype.median
    141 
    142 Returns the [median][median].
    143 
    144 ```javascript
    145 var discreteUniform = new DiscreteUniform( 4, 12 );
    146 
    147 var median = discreteUniform.median;
    148 // returns 8.0
    149 ```
    150 
    151 #### DiscreteUniform.prototype.skewness
    152 
    153 Returns the [skewness][skewness].
    154 
    155 ```javascript
    156 var discreteUniform = new DiscreteUniform( 4, 12 );
    157 
    158 var skewness = discreteUniform.skewness;
    159 // returns 0.0
    160 ```
    161 
    162 #### DiscreteUniform.prototype.stdev
    163 
    164 Returns the [standard deviation][standard-deviation].
    165 
    166 ```javascript
    167 var discreteUniform = new DiscreteUniform( 4, 12 );
    168 
    169 var s = discreteUniform.stdev;
    170 // returns ~2.582
    171 ```
    172 
    173 #### DiscreteUniform.prototype.variance
    174 
    175 Returns the [variance][variance].
    176 
    177 ```javascript
    178 var discreteUniform = new DiscreteUniform( 4, 12 );
    179 
    180 var s2 = discreteUniform.variance;
    181 // returns ~6.667
    182 ```
    183 
    184 * * *
    185 
    186 ### Methods
    187 
    188 #### DiscreteUniform.prototype.cdf( x )
    189 
    190 Evaluates the [cumulative distribution function][cdf] (CDF).
    191 
    192 ```javascript
    193 var discreteUniform = new DiscreteUniform( 2, 4 );
    194 
    195 var y = discreteUniform.cdf( 2.5 );
    196 // returns ~0.333
    197 ```
    198 
    199 #### DiscreteUniform.prototype.logcdf( x )
    200 
    201 Evaluates the natural logarithm of the [cumulative distribution function][cdf] (CDF).
    202 
    203 ```javascript
    204 var discreteUniform = new DiscreteUniform( 2, 4 );
    205 
    206 var y = discreteUniform.logcdf( 2.5 );
    207 // returns ~-1.099
    208 ```
    209 
    210 #### DiscreteUniform.prototype.logpmf( x )
    211 
    212 Evaluates the natural logarithm of the [probability mass function][pmf] (PMF).
    213 
    214 ```javascript
    215 var discreteUniform = new DiscreteUniform( 2, 4 );
    216 
    217 var y = discreteUniform.logpmf( 4.0 );
    218 // returns ~-1.099
    219 ```
    220 
    221 #### DiscreteUniform.prototype.pmf( x )
    222 
    223 Evaluates the [probability mass function][pmf] (PMF).
    224 
    225 ```javascript
    226 var discreteUniform = new DiscreteUniform( 2, 4 );
    227 
    228 var y = discreteUniform.pmf( 3, 0 );
    229 // returns ~0.333
    230 ```
    231 
    232 #### DiscreteUniform.prototype.quantile( p )
    233 
    234 Evaluates the [quantile function][quantile-function] at probability `p`.
    235 
    236 ```javascript
    237 var discreteUniform = new DiscreteUniform( 2, 4 );
    238 
    239 var y = discreteUniform.quantile( 0.5 );
    240 // returns 3.0
    241 
    242 y = discreteUniform.quantile( 1.9 );
    243 // returns NaN
    244 ```
    245 
    246 </section>
    247 
    248 <!-- /.usage -->
    249 
    250 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    251 
    252 <section class="notes">
    253 
    254 </section>
    255 
    256 <!-- /.notes -->
    257 
    258 <!-- Package usage examples. -->
    259 
    260 * * *
    261 
    262 <section class="examples">
    263 
    264 ## Examples
    265 
    266 <!-- eslint no-undef: "error" -->
    267 
    268 ```javascript
    269 var DiscreteUniform = require( '@stdlib/stats/base/dists/discrete-uniform/ctor' );
    270 
    271 var discreteUniform = new DiscreteUniform( -2, 2 );
    272 
    273 var mu = discreteUniform.mean;
    274 // returns 0.0
    275 
    276 var median = discreteUniform.median;
    277 // returns 0.0
    278 
    279 var s2 = discreteUniform.variance;
    280 // returns 2.0
    281 
    282 var y = discreteUniform.cdf( 2.5 );
    283 // returns 1.0
    284 ```
    285 
    286 </section>
    287 
    288 <!-- /.examples -->
    289 
    290 <!-- 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. -->
    291 
    292 <section class="references">
    293 
    294 </section>
    295 
    296 <!-- /.references -->
    297 
    298 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    299 
    300 <section class="links">
    301 
    302 [discrete-uniform-distribution]: https://en.wikipedia.org/wiki/Discrete_uniform_distribution
    303 
    304 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
    305 
    306 [pmf]: https://en.wikipedia.org/wiki/Probability_mass_function
    307 
    308 [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function
    309 
    310 [entropy]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29
    311 
    312 [expected-value]: https://en.wikipedia.org/wiki/Expected_value
    313 
    314 [kurtosis]: https://en.wikipedia.org/wiki/Kurtosis
    315 
    316 [median]: https://en.wikipedia.org/wiki/Median
    317 
    318 [skewness]: https://en.wikipedia.org/wiki/Skewness
    319 
    320 [standard-deviation]: https://en.wikipedia.org/wiki/Standard_deviation
    321 
    322 [variance]: https://en.wikipedia.org/wiki/Variance
    323 
    324 </section>
    325 
    326 <!-- /.links -->