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