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