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