time-to-botec

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

README.md (6335B)


      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 # Uniform
     22 
     23 > Uniform 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 Uniform = require( '@stdlib/stats/base/dists/uniform/ctor' );
     41 ```
     42 
     43 #### Uniform( \[a, b] )
     44 
     45 Returns an [uniform][uniform-distribution] distribution object.
     46 
     47 ```javascript
     48 var uniform = new Uniform();
     49 
     50 var mu = uniform.mean;
     51 // returns 0.5
     52 ```
     53 
     54 By default, `a = 0.0` and `b = 1.0`. To create a distribution having a different `a` (minimum support) and `b` (maximum support), provide the corresponding arguments.
     55 
     56 ```javascript
     57 var uniform = new Uniform( 2.0, 4.0 );
     58 
     59 var mu = uniform.mean;
     60 // returns 3.0
     61 ```
     62 
     63 * * *
     64 
     65 ## uniform
     66 
     67 An [uniform][uniform-distribution] distribution object has the following properties and methods...
     68 
     69 ### Writable Properties
     70 
     71 #### uniform.a
     72 
     73 Minimum support of the distribution. `a` **must** be a number smaller than `b`.
     74 
     75 ```javascript
     76 var uniform = new Uniform();
     77 
     78 var a = uniform.a;
     79 // returns 0.0
     80 
     81 uniform.a = 0.5;
     82 
     83 a = uniform.a;
     84 // returns 0.5
     85 ```
     86 
     87 #### uniform.b
     88 
     89 Maximum support of the distribution. `b` **must** be a number larger than `a`.
     90 
     91 ```javascript
     92 var uniform = new Uniform( 2.0, 4.0 );
     93 
     94 var b = uniform.b;
     95 // returns 4.0
     96 
     97 uniform.b = 3.0;
     98 
     99 b = uniform.b;
    100 // returns 3.0
    101 ```
    102 
    103 * * *
    104 
    105 ### Computed Properties
    106 
    107 #### Uniform.prototype.entropy
    108 
    109 Returns the [differential entropy][entropy].
    110 
    111 ```javascript
    112 var uniform = new Uniform( 4.0, 12.0 );
    113 
    114 var entropy = uniform.entropy;
    115 // returns ~2.079
    116 ```
    117 
    118 #### Uniform.prototype.kurtosis
    119 
    120 Returns the [excess kurtosis][kurtosis].
    121 
    122 ```javascript
    123 var uniform = new Uniform( 4.0, 12.0 );
    124 
    125 var kurtosis = uniform.kurtosis;
    126 // returns -1.2
    127 ```
    128 
    129 #### Uniform.prototype.mean
    130 
    131 Returns the [expected value][expected-value].
    132 
    133 ```javascript
    134 var uniform = new Uniform( 4.0, 12.0 );
    135 
    136 var mu = uniform.mean;
    137 // returns 8.0
    138 ```
    139 
    140 #### Uniform.prototype.median
    141 
    142 Returns the [median][median].
    143 
    144 ```javascript
    145 var uniform = new Uniform( 4.0, 12.0 );
    146 
    147 var median = uniform.median;
    148 // returns 8.0
    149 ```
    150 
    151 #### Uniform.prototype.skewness
    152 
    153 Returns the [skewness][skewness].
    154 
    155 ```javascript
    156 var uniform = new Uniform( 4.0, 12.0 );
    157 
    158 var skewness = uniform.skewness;
    159 // returns 0.0
    160 ```
    161 
    162 #### Uniform.prototype.stdev
    163 
    164 Returns the [standard deviation][standard-deviation].
    165 
    166 ```javascript
    167 var uniform = new Uniform( 4.0, 12.0 );
    168 
    169 var s = uniform.stdev;
    170 // returns ~2.309
    171 ```
    172 
    173 #### Uniform.prototype.variance
    174 
    175 Returns the [variance][variance].
    176 
    177 ```javascript
    178 var uniform = new Uniform( 4.0, 12.0 );
    179 
    180 var s2 = uniform.variance;
    181 // returns ~5.333
    182 ```
    183 
    184 * * *
    185 
    186 ### Methods
    187 
    188 #### Uniform.prototype.cdf( x )
    189 
    190 Evaluates the [cumulative distribution function][cdf] (CDF).
    191 
    192 ```javascript
    193 var uniform = new Uniform( 2.0, 4.0 );
    194 
    195 var y = uniform.cdf( 2.5 );
    196 // returns 0.25
    197 ```
    198 
    199 #### Uniform.prototype.logcdf( x )
    200 
    201 Evaluates the natural logarithm of the [cumulative distribution function][cdf] (CDF).
    202 
    203 ```javascript
    204 var uniform = new Uniform( 2.0, 4.0 );
    205 
    206 var y = uniform.logcdf( 2.5 );
    207 // returns ~-1.386
    208 ```
    209 
    210 #### Uniform.prototype.logpdf( x )
    211 
    212 Evaluates the natural logarithm of the [probability density function][pdf] (PDF).
    213 
    214 ```javascript
    215 var uniform = new Uniform( 2.0, 4.0 );
    216 
    217 var y = uniform.logpdf( 2.5 );
    218 // returns ~-0.693
    219 ```
    220 
    221 #### Uniform.prototype.pdf( x )
    222 
    223 Evaluates the [probability density function][pdf] (PDF).
    224 
    225 ```javascript
    226 var uniform = new Uniform( 2.0, 4.0 );
    227 
    228 var y = uniform.pdf( 2.5 );
    229 // returns 0.5
    230 ```
    231 
    232 #### Uniform.prototype.quantile( p )
    233 
    234 Evaluates the [quantile function][quantile-function] at probability `p`.
    235 
    236 ```javascript
    237 var uniform = new Uniform( 2.0, 4.0 );
    238 
    239 var y = uniform.quantile( 0.5 );
    240 // returns 3.0
    241 
    242 y = uniform.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 Uniform = require( '@stdlib/stats/base/dists/uniform/ctor' );
    270 
    271 var uniform = new Uniform( 2.0, 4.0 );
    272 
    273 var mu = uniform.mean;
    274 // returns 3.0
    275 
    276 var median = uniform.median;
    277 // returns 3.0
    278 
    279 var s2 = uniform.variance;
    280 // returns ~0.333
    281 
    282 var y = uniform.cdf( 2.5 );
    283 // returns 0.25
    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 [uniform-distribution]: https://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29
    303 
    304 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
    305 
    306 [pdf]: https://en.wikipedia.org/wiki/Probability_density_function
    307 
    308 [quantile-function]: https://en.wikipedia.org/wiki/Quantile_function
    309 
    310 [entropy]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29
    311 
    312 [expected-value]: https://en.wikipedia.org/wiki/Expected_value
    313 
    314 [kurtosis]: https://en.wikipedia.org/wiki/Kurtosis
    315 
    316 [median]: https://en.wikipedia.org/wiki/Median
    317 
    318 [skewness]: https://en.wikipedia.org/wiki/Skewness
    319 
    320 [standard-deviation]: https://en.wikipedia.org/wiki/Standard_deviation
    321 
    322 [variance]: https://en.wikipedia.org/wiki/Variance
    323 
    324 </section>
    325 
    326 <!-- /.links -->