time-to-botec

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

README.md (3957B)


      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 # Cumulative Distribution Function
     22 
     23 > [Weibull][weibull-distribution] distribution [cumulative distribution function][cdf].
     24 
     25 <section class="intro">
     26 
     27 The [cumulative distribution function][cdf] for a [Weibull][weibull-distribution] random variable is
     28 
     29 <!-- <equation class="equation" label="eq:weibull_cdf" align="center" raw="F(x;\lambda, k) =\begin{cases}1- e^{-(x/\lambda)^k} & x \geq 0 \\ 0 & x<0\end{cases}" alt="Cumulative distribution function for a Weibull distribution."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="F(x;\lambda, k) =\begin{cases}1- e^{-(x/\lambda)^k} &amp; x \geq 0 \\ 0 &amp; x&lt;0\end{cases}" data-equation="eq:weibull_cdf">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/weibull/cdf/docs/img/equation_weibull_cdf.svg" alt="Cumulative distribution function for a Weibull distribution.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 where `lambda > 0` is the [shape parameter][shape] and `k > 0` is the [scale parameter][scale].
     39 
     40 </section>
     41 
     42 <!-- /.intro -->
     43 
     44 <section class="usage">
     45 
     46 ## Usage
     47 
     48 ```javascript
     49 var cdf = require( '@stdlib/stats/base/dists/weibull/cdf' );
     50 ```
     51 
     52 #### cdf( x, k, lambda )
     53 
     54 Evaluates the [cumulative distribution function][cdf] (CDF) for a [Weibull][weibull-distribution] distribution with [shape parameter][shape] `k` and [scale parameter][scale] `lambda`.
     55 
     56 ```javascript
     57 var y = cdf( 2.0, 1.0, 0.5 );
     58 // returns ~0.982
     59 
     60 y = cdf( 0.0, 1.0, 0.5 );
     61 // returns 0.0
     62 
     63 y = cdf( -Infinity, 4.0, 2.0 );
     64 // returns 0.0
     65 
     66 y = cdf( +Infinity, 4.0, 2.0 );
     67 // returns 1.0
     68 ```
     69 
     70 If provided `NaN` as any argument, the function returns `NaN`.
     71 
     72 ```javascript
     73 var y = cdf( NaN, 1.0, 1.0 );
     74 // returns NaN
     75 
     76 y = cdf( 0.0, NaN, 1.0 );
     77 // returns NaN
     78 
     79 y = cdf( 0.0, 1.0, NaN );
     80 // returns NaN
     81 ```
     82 
     83 If provided `k <= 0`, the function returns `NaN`.
     84 
     85 ```javascript
     86 var y = cdf( 2.0, 0.5, -1.0 );
     87 // returns NaN
     88 
     89 y = cdf( 2.0, 0.5, 0.0 );
     90 // returns NaN
     91 ```
     92 
     93 If provided `lambda <= 0`, the function returns `NaN`.
     94 
     95 ```javascript
     96 var y = cdf( 2.0, 0.5, -1.0 );
     97 // returns NaN
     98 
     99 y = cdf( 2.0, 0.5, 0.0 );
    100 // returns NaN
    101 ```
    102 
    103 #### cdf.factory( k, lambda )
    104 
    105 Returns a function for evaluating the [cumulative distribution function][cdf] of a [Weibull][weibull-distribution] distribution with [shape parameter][shape] `k` and [scale parameter][scale] `lambda`.
    106 
    107 ```javascript
    108 var mycdf = cdf.factory( 2.0, 10.0 );
    109 
    110 var y = mycdf( 10.0 );
    111 // returns ~0.632
    112 
    113 y = mycdf( 8.0 );
    114 // returns ~0.473
    115 ```
    116 
    117 </section>
    118 
    119 <!-- /.usage -->
    120 
    121 <section class="examples">
    122 
    123 ## Examples
    124 
    125 <!-- eslint no-undef: "error" -->
    126 
    127 ```javascript
    128 var randu = require( '@stdlib/random/base/randu' );
    129 var cdf = require( '@stdlib/stats/base/dists/weibull/cdf' );
    130 
    131 var lambda;
    132 var k;
    133 var x;
    134 var y;
    135 var i;
    136 
    137 for ( i = 0; i < 10; i++ ) {
    138     x = randu() * 10.0;
    139     lambda = randu() * 10.0;
    140     k = randu() * 10.0;
    141     y = cdf( x, lambda, k );
    142     console.log( 'x: %d, k: %d, λ: %d, F(x;k,λ): %d', x, k, lambda, y );
    143 }
    144 ```
    145 
    146 </section>
    147 
    148 <!-- /.examples -->
    149 
    150 <section class="links">
    151 
    152 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
    153 
    154 [weibull-distribution]: https://en.wikipedia.org/wiki/Weibull_distribution
    155 
    156 [shape]: https://en.wikipedia.org/wiki/Shape_parameter
    157 
    158 [scale]: https://en.wikipedia.org/wiki/Scale_parameter
    159 
    160 </section>
    161 
    162 <!-- /.links -->