time-to-botec

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

README.md (6761B)


      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 # Laplace
     22 
     23 > Laplace 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 Laplace = require( '@stdlib/stats/base/dists/laplace/ctor' );
     41 ```
     42 
     43 #### Laplace( \[mu, b] )
     44 
     45 Returns a [Laplace][laplace-distribution] distribution object.
     46 
     47 ```javascript
     48 var laplace = new Laplace();
     49 
     50 var mu = laplace.mean;
     51 // returns 0.0
     52 ```
     53 
     54 By default, `mu = 0.0` and `b = 1.0`. To create a distribution having a different `mu` (location parameter) and `b` (scale parameter), provide the corresponding arguments.
     55 
     56 ```javascript
     57 var laplace = new Laplace( 2.0, 4.0 );
     58 
     59 var mu = laplace.mean;
     60 // returns 2.0
     61 ```
     62 
     63 * * *
     64 
     65 ## laplace
     66 
     67 A [Laplace][laplace-distribution] distribution object has the following properties and methods...
     68 
     69 ### Writable Properties
     70 
     71 #### laplace.mu
     72 
     73 Location parameter of the distribution.
     74 
     75 ```javascript
     76 var laplace = new Laplace();
     77 
     78 var mu = laplace.mu;
     79 // returns 0.0
     80 
     81 laplace.mu = 3.0;
     82 
     83 mu = laplace.mu;
     84 // returns 3.0
     85 ```
     86 
     87 #### laplace.b
     88 
     89 Scale parameter of the distribution. `b` **must** be a positive number.
     90 
     91 ```javascript
     92 var laplace = new Laplace( 2.0, 4.0 );
     93 
     94 var b = laplace.b;
     95 // returns 4.0
     96 
     97 laplace.b = 3.0;
     98 
     99 b = laplace.b;
    100 // returns 3.0
    101 ```
    102 
    103 * * *
    104 
    105 ### Computed Properties
    106 
    107 #### Laplace.prototype.entropy
    108 
    109 Returns the [differential entropy][entropy].
    110 
    111 ```javascript
    112 var laplace = new Laplace( 4.0, 12.0 );
    113 
    114 var entropy = laplace.entropy;
    115 // returns ~4.178
    116 ```
    117 
    118 #### Laplace.prototype.kurtosis
    119 
    120 Returns the [excess kurtosis][kurtosis].
    121 
    122 ```javascript
    123 var laplace = new Laplace( 4.0, 12.0 );
    124 
    125 var kurtosis = laplace.kurtosis;
    126 // returns 3.0
    127 ```
    128 
    129 #### Laplace.prototype.mean
    130 
    131 Returns the [expected value][expected-value].
    132 
    133 ```javascript
    134 var laplace = new Laplace( 4.0, 12.0 );
    135 
    136 var mu = laplace.mean;
    137 // returns 4.0
    138 ```
    139 
    140 #### Laplace.prototype.median
    141 
    142 Returns the [median][median].
    143 
    144 ```javascript
    145 var laplace = new Laplace( 4.0, 12.0 );
    146 
    147 var median = laplace.median;
    148 // returns 4.0
    149 ```
    150 
    151 #### Laplace.prototype.mode
    152 
    153 Returns the [mode][mode].
    154 
    155 ```javascript
    156 var laplace = new Laplace( 4.0, 12.0 );
    157 
    158 var mode = laplace.mode;
    159 // returns 4.0
    160 ```
    161 
    162 #### Laplace.prototype.skewness
    163 
    164 Returns the [skewness][skewness].
    165 
    166 ```javascript
    167 var laplace = new Laplace( 4.0, 12.0 );
    168 
    169 var skewness = laplace.skewness;
    170 // returns 0.0
    171 ```
    172 
    173 #### Laplace.prototype.stdev
    174 
    175 Returns the [standard deviation][standard-deviation].
    176 
    177 ```javascript
    178 var laplace = new Laplace( 4.0, 12.0 );
    179 
    180 var s = laplace.stdev;
    181 // returns ~16.971
    182 ```
    183 
    184 #### Laplace.prototype.variance
    185 
    186 Returns the [variance][variance].
    187 
    188 ```javascript
    189 var laplace = new Laplace( 4.0, 12.0 );
    190 
    191 var s2 = laplace.variance;
    192 // returns 288.0
    193 ```
    194 
    195 * * *
    196 
    197 ### Methods
    198 
    199 #### Laplace.prototype.cdf( x )
    200 
    201 Evaluates the [cumulative distribution function][cdf] (CDF).
    202 
    203 ```javascript
    204 var laplace = new Laplace( 2.0, 4.0 );
    205 
    206 var y = laplace.cdf( 0.5 );
    207 // returns ~0.344
    208 ```
    209 
    210 #### Laplace.prototype.logcdf( x )
    211 
    212 Evaluates the natural logarithm of the [cumulative distribution function][cdf] (CDF).
    213 
    214 ```javascript
    215 var laplace = new Laplace( 2.0, 4.0 );
    216 
    217 var y = laplace.logcdf( 2.0 );
    218 // returns ~-0.693
    219 ```
    220 
    221 #### Laplace.prototype.logpdf( x )
    222 
    223 Evaluates the natural logarithm of the [probability density function][pdf] (PDF).
    224 
    225 ```javascript
    226 var laplace = new Laplace( 2.0, 4.0 );
    227 
    228 var y = laplace.logpdf( 0.8 );
    229 // returns ~-2.379
    230 ```
    231 
    232 #### Laplace.prototype.mgf( t )
    233 
    234 Evaluates the [moment-generating function][mgf] (MGF).
    235 
    236 ```javascript
    237 var laplace = new Laplace( 2.0, 4.0 );
    238 
    239 var y = laplace.mgf( 0.2 );
    240 // returns ~4.144
    241 ```
    242 
    243 #### Laplace.prototype.pdf( x )
    244 
    245 Evaluates the [probability density function][pdf] (PDF).
    246 
    247 ```javascript
    248 var laplace = new Laplace( 2.0, 4.0 );
    249 
    250 var y = laplace.pdf( 2.0 );
    251 // returns 0.125
    252 ```
    253 
    254 #### Laplace.prototype.quantile( p )
    255 
    256 Evaluates the [quantile function][quantile-function] at probability `p`.
    257 
    258 ```javascript
    259 var laplace = new Laplace( 2.0, 4.0 );
    260 
    261 var y = laplace.quantile( 0.5 );
    262 // returns 2.0
    263 
    264 y = laplace.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 Laplace = require( '@stdlib/stats/base/dists/laplace/ctor' );
    292 
    293 var laplace = new Laplace( 2.0, 4.0 );
    294 
    295 var mean = laplace.mean;
    296 // returns 2.0
    297 
    298 var median = laplace.median;
    299 // returns 2.0
    300 
    301 var s2 = laplace.variance;
    302 // returns 32.0
    303 
    304 var y = laplace.cdf( 0.8 );
    305 // returns ~0.37
    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 [laplace-distribution]: https://en.wikipedia.org/wiki/Laplace_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 -->