time-to-botec

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

README.md (6134B)


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