time-to-botec

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

README.md (6473B)


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