time-to-botec

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

README.md (6615B)


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