time-to-botec

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

README.md (7272B)


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