time-to-botec

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

README.md (6678B)


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