README.md (6649B)
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 # Weibull 22 23 > Weibull 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 Weibull = require( '@stdlib/stats/base/dists/weibull/ctor' ); 41 ``` 42 43 #### Weibull( \[k, lambda] ) 44 45 Returns a [Weibull][weibull-distribution] distribution object. 46 47 ```javascript 48 var weibull = new Weibull(); 49 50 var mode = weibull.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` (scale parameter), provide the corresponding arguments. 55 56 ```javascript 57 var weibull = new Weibull( 2.0, 4.0 ); 58 59 var mode = weibull.mode; 60 // returns ~2.828 61 ``` 62 63 * * * 64 65 ## weibull 66 67 A [Weibull][weibull-distribution] distribution object has the following properties and methods... 68 69 ### Writable Properties 70 71 #### weibull.k 72 73 Shape parameter of the distribution. `k` **must** be a positive number. 74 75 ```javascript 76 var weibull = new Weibull(); 77 78 var k = weibull.k; 79 // returns 1.0 80 81 weibull.k = 3.0; 82 83 k = weibull.k; 84 // returns 3.0 85 ``` 86 87 #### weibull.lambda 88 89 Scale parameter of the distribution. `lambda` **must** be a positive number. 90 91 ```javascript 92 var weibull = new Weibull( 2.0, 4.0 ); 93 94 var lambda = weibull.lambda; 95 // returns 4.0 96 97 weibull.lambda = 3.0; 98 99 lambda = weibull.lambda; 100 // returns 3.0 101 ``` 102 103 * * * 104 105 ### Computed Properties 106 107 #### Weibull.prototype.entropy 108 109 Returns the [differential entropy][entropy]. 110 111 ```javascript 112 var weibull = new Weibull( 4.0, 12.0 ); 113 114 var entropy = weibull.entropy; 115 // returns ~2.532 116 ``` 117 118 #### Weibull.prototype.kurtosis 119 120 Returns the [excess kurtosis][kurtosis]. 121 122 ```javascript 123 var weibull = new Weibull( 4.0, 12.0 ); 124 125 var kurtosis = weibull.kurtosis; 126 // returns ~-0.252 127 ``` 128 129 #### Weibull.prototype.mean 130 131 Returns the [expected value][expected-value]. 132 133 ```javascript 134 var weibull = new Weibull( 4.0, 12.0 ); 135 136 var mu = weibull.mean; 137 // returns ~10.877 138 ``` 139 140 #### Weibull.prototype.mode 141 142 Returns the [mode][mode]. 143 144 ```javascript 145 var weibull = new Weibull( 4.0, 12.0 ); 146 147 var mode = weibull.mode; 148 // returns ~11.167 149 ``` 150 151 #### Weibull.prototype.skewness 152 153 Returns the [skewness][skewness]. 154 155 ```javascript 156 var weibull = new Weibull( 4.0, 12.0 ); 157 158 var skewness = weibull.skewness; 159 // returns ~-0.087 160 ``` 161 162 #### Weibull.prototype.stdev 163 164 Returns the [standard deviation][standard-deviation]. 165 166 ```javascript 167 var weibull = new Weibull( 4.0, 12.0 ); 168 169 var s = weibull.stdev; 170 // returns ~3.051 171 ``` 172 173 #### Weibull.prototype.variance 174 175 Returns the [variance][variance]. 176 177 ```javascript 178 var weibull = new Weibull( 4.0, 12.0 ); 179 180 var s2 = weibull.variance; 181 // returns ~9.311 182 ``` 183 184 * * * 185 186 ### Methods 187 188 #### Weibull.prototype.cdf( x ) 189 190 Evaluates the [cumulative distribution function][cdf] (CDF). 191 192 ```javascript 193 var weibull = new Weibull( 2.0, 4.0 ); 194 195 var y = weibull.cdf( 0.5 ); 196 // returns ~0.016 197 ``` 198 199 #### Weibull.prototype.logcdf( x ) 200 201 Evaluates the natural logarithm of the [cumulative distribution function][cdf] (logCDF). 202 203 ```javascript 204 var weibull = new Weibull( 2.0, 4.0 ); 205 206 var y = weibull.logcdf( 0.8 ); 207 // returns ~-3.239 208 ``` 209 210 #### Weibull.prototype.logpdf( x ) 211 212 Evaluates the natural logarithm of the [probability density function][pdf] (PDF). 213 214 ```javascript 215 var weibull = new Weibull( 2.0, 4.0 ); 216 217 var y = weibull.logpdf( 0.8 ); 218 // returns ~-2.343 219 ``` 220 221 #### Weibull.prototype.mgf( t ) 222 223 Evaluates the [moment-generating function][mgf] (MGF). 224 225 ```javascript 226 var weibull = new Weibull( 2.0, 4.0 ); 227 228 var y = weibull.mgf( 0.5 ); 229 // returns ~9.878 230 ``` 231 232 #### Weibull.prototype.pdf( x ) 233 234 Evaluates the [probability density function][pdf] (PDF). 235 236 ```javascript 237 var weibull = new Weibull( 2.0, 4.0 ); 238 239 var y = weibull.pdf( 0.8 ); 240 // returns ~0.096 241 ``` 242 243 #### Weibull.prototype.quantile( p ) 244 245 Evaluates the [quantile function][quantile-function] at probability `p`. 246 247 ```javascript 248 var weibull = new Weibull( 2.0, 4.0 ); 249 250 var y = weibull.quantile( 0.5 ); 251 // returns ~3.33 252 253 y = weibull.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 Weibull = require( '@stdlib/stats/base/dists/weibull/ctor' ); 281 282 var weibull = new Weibull( 2.0, 4.0 ); 283 284 var mu = weibull.mean; 285 // returns ~3.545 286 287 var mode = weibull.mode; 288 // returns ~2.828 289 290 var s2 = weibull.variance; 291 // returns ~3.434 292 293 var y = weibull.cdf( 0.8 ); 294 // returns ~0.039 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 [weibull-distribution]: https://en.wikipedia.org/wiki/Weibull_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 [mode]: https://en.wikipedia.org/wiki/Mode_%28statistics%29 330 331 [skewness]: https://en.wikipedia.org/wiki/Skewness 332 333 [standard-deviation]: https://en.wikipedia.org/wiki/Standard_deviation 334 335 [variance]: https://en.wikipedia.org/wiki/Variance 336 337 </section> 338 339 <!-- /.links -->