time-to-botec

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

README.md (6670B)


      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 # Hypergeometric
     22 
     23 > Hypergeometric 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 Hypergeometric = require( '@stdlib/stats/base/dists/hypergeometric/ctor' );
     41 ```
     42 
     43 #### Hypergeometric( N, K, n )
     44 
     45 Returns a [hypergeometric][hypergeometric-distribution] distribution object with parameters `N` (population size), `K` (subpopulation size), and `n` (number of draws).
     46 
     47 ```javascript
     48 var hypergeometric = new Hypergeometric( 20, 15, 5 );
     49 
     50 var mu = hypergeometric.mean;
     51 // returns 3.75
     52 ```
     53 
     54 * * *
     55 
     56 ## hypergeometric
     57 
     58 A [hypergeometric][hypergeometric-distribution] distribution object has the following properties and methods...
     59 
     60 ### Writable Properties
     61 
     62 #### hypergeometric.N
     63 
     64 Population size of the distribution. `N` **must** be a nonnegative integer that is both larger than or equal to `K` and `n`.
     65 
     66 ```javascript
     67 var hypergeometric = new Hypergeometric( 100, 50, 20 );
     68 
     69 var N = hypergeometric.N;
     70 // returns 100.0
     71 
     72 hypergeometric.N = 60;
     73 
     74 N = hypergeometric.N;
     75 // returns 60.0
     76 ```
     77 
     78 #### hypergeometric.K
     79 
     80 Subpopulation size of the distribution. `K` **must** be a nonnegative integer that is smaller than or equal to `N`.
     81 
     82 ```javascript
     83 var hypergeometric = new Hypergeometric( 100, 50, 20 );
     84 
     85 var K = hypergeometric.K;
     86 // returns 50.0
     87 
     88 hypergeometric.K = 30;
     89 
     90 K = hypergeometric.K;
     91 // returns 30.0
     92 ```
     93 
     94 <!--lint disable no-duplicate-headings-in-section -->
     95 
     96 #### hypergeometric.n
     97 
     98 Number of draws of the distribution. `n` **must** be a nonnegative integer that is smaller than or equal to `N`.
     99 
    100 ```javascript
    101 var hypergeometric = new Hypergeometric( 100, 50, 20 );
    102 
    103 var n = hypergeometric.n;
    104 // returns 20.0
    105 
    106 hypergeometric.n = 80;
    107 
    108 n = hypergeometric.n;
    109 // returns 80.0
    110 ```
    111 
    112 * * *
    113 
    114 ### Computed Properties
    115 
    116 #### Hypergeometric.prototype.kurtosis
    117 
    118 Returns the [excess kurtosis][kurtosis].
    119 
    120 ```javascript
    121 var hypergeometric = new Hypergeometric( 20, 15, 5 );
    122 
    123 var kurtosis = hypergeometric.kurtosis;
    124 // returns ~-0.276
    125 ```
    126 
    127 #### Hypergeometric.prototype.mean
    128 
    129 Returns the [expected value][expected-value].
    130 
    131 ```javascript
    132 var hypergeometric = new Hypergeometric( 20, 15, 5 );
    133 
    134 var mu = hypergeometric.mean;
    135 // returns ~3.75
    136 ```
    137 
    138 #### Hypergeometric.prototype.mode
    139 
    140 Returns the [mode][mode].
    141 
    142 ```javascript
    143 var hypergeometric = new Hypergeometric( 20, 15, 5 );
    144 
    145 var mode = hypergeometric.mode;
    146 // returns 4.0
    147 ```
    148 
    149 #### Hypergeometric.prototype.skewness
    150 
    151 Returns the [skewness][skewness].
    152 
    153 ```javascript
    154 var hypergeometric = new Hypergeometric( 20, 15, 5 );
    155 
    156 var skewness = hypergeometric.skewness;
    157 // returns ~-0.323
    158 ```
    159 
    160 #### Hypergeometric.prototype.stdev
    161 
    162 Returns the [standard deviation][standard-deviation].
    163 
    164 ```javascript
    165 var hypergeometric = new Hypergeometric( 20, 15, 5 );
    166 
    167 var s = hypergeometric.stdev;
    168 // returns ~0.86
    169 ```
    170 
    171 #### Hypergeometric.prototype.variance
    172 
    173 Returns the [variance][variance].
    174 
    175 ```javascript
    176 var hypergeometric = new Hypergeometric( 20, 15, 5 );
    177 
    178 var s2 = hypergeometric.variance;
    179 // returns ~0.74
    180 ```
    181 
    182 * * *
    183 
    184 ### Methods
    185 
    186 #### Hypergeometric.prototype.cdf( x )
    187 
    188 Evaluates the [cumulative distribution function][cdf] (CDF).
    189 
    190 ```javascript
    191 var hypergeometric = new Hypergeometric( 8, 2, 4 );
    192 
    193 var y = hypergeometric.cdf( 0.5 );
    194 // returns ~0.214
    195 ```
    196 
    197 #### Hypergeometric.prototype.logpmf( x )
    198 
    199 Evaluates the natural logarithm of the [probability mass function][pmf] (PMF).
    200 
    201 ```javascript
    202 var hypergeometric = new Hypergeometric( 8, 2, 4 );
    203 
    204 var y = hypergeometric.logpmf( 2.0 );
    205 // returns ~-1.54
    206 ```
    207 
    208 #### Hypergeometric.prototype.pmf( x )
    209 
    210 Evaluates the [probability mass function][pmf] (PMF).
    211 
    212 ```javascript
    213 var hypergeometric = new Hypergeometric( 8, 2, 4 );
    214 
    215 var y = hypergeometric.pmf( 2.0 );
    216 // returns ~0.214
    217 ```
    218 
    219 #### Hypergeometric.prototype.quantile( p )
    220 
    221 Evaluates the [quantile function][quantile-function] at probability `p`.
    222 
    223 ```javascript
    224 var hypergeometric = new Hypergeometric( 8, 2, 4 );
    225 
    226 var y = hypergeometric.quantile( 0.8 );
    227 // returns 2.0
    228 
    229 y = hypergeometric.quantile( 1.9 );
    230 // returns NaN
    231 ```
    232 
    233 </section>
    234 
    235 <!-- /.usage -->
    236 
    237 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    238 
    239 <section class="notes">
    240 
    241 </section>
    242 
    243 <!-- /.notes -->
    244 
    245 <!-- Package usage examples. -->
    246 
    247 * * *
    248 
    249 <section class="examples">
    250 
    251 ## Examples
    252 
    253 <!-- eslint no-undef: "error" -->
    254 
    255 ```javascript
    256 var Hypergeometric = require( '@stdlib/stats/base/dists/hypergeometric/ctor' );
    257 
    258 var hypergeometric = new Hypergeometric( 100, 50, 20 );
    259 
    260 var mu = hypergeometric.mean;
    261 // returns 10.0
    262 
    263 var mode = hypergeometric.mode;
    264 // returns 10.0
    265 
    266 var s2 = hypergeometric.variance;
    267 // returns ~4.04
    268 
    269 var y = hypergeometric.cdf( 10.5 );
    270 // returns ~0.598
    271 ```
    272 
    273 </section>
    274 
    275 <!-- /.examples -->
    276 
    277 <!-- 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. -->
    278 
    279 <section class="references">
    280 
    281 </section>
    282 
    283 <!-- /.references -->
    284 
    285 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    286 
    287 <section class="links">
    288 
    289 [hypergeometric-distribution]: https://en.wikipedia.org/wiki/Hypergeometric_distribution
    290 
    291 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
    292 
    293 [pmf]: https://en.wikipedia.org/wiki/Probability_mass_function
    294 
    295 [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function
    296 
    297 [expected-value]: https://en.wikipedia.org/wiki/Expected_value
    298 
    299 [kurtosis]: https://en.wikipedia.org/wiki/Kurtosis
    300 
    301 [mode]: https://en.wikipedia.org/wiki/Mode_%28statistics%29
    302 
    303 [skewness]: https://en.wikipedia.org/wiki/Skewness
    304 
    305 [standard-deviation]: https://en.wikipedia.org/wiki/Standard_deviation
    306 
    307 [variance]: https://en.wikipedia.org/wiki/Variance
    308 
    309 </section>
    310 
    311 <!-- /.links -->