time-to-botec

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

README.md (3055B)


      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 > [Degenerate distribution][degenerate-distribution] [cumulative distribution function][cdf].
     24 
     25 <section class="intro">
     26 
     27 The [cumulative distribution function][cdf] for a [degenerate][degenerate-distribution] random variable is
     28 
     29 <!-- <equation class="equation" label="eq:degenerate_cdf" align="center" raw="F(x;\mu)={\begin{cases}1, & x \geq \mu,\\0,& x < \mu.\end{cases}}" alt="Cumulative distribution function for a degenerate distribution."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="F(x;\mu)={\begin{cases}1, &amp; x \geq \mu,\\0,&amp; x &lt; \mu.\end{cases}}" data-equation="eq:degenerate_cdf">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/degenerate/cdf/docs/img/equation_degenerate_cdf.svg" alt="Cumulative distribution function for a degenerate distribution.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 where `µ` is the constant value of the distribution.
     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/degenerate/cdf' );
     50 ```
     51 
     52 #### cdf( x, mu )
     53 
     54 Evaluates the [CDF][cdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     55 
     56 ```javascript
     57 var y = cdf( 2.0, 8.0 );
     58 // returns 0.0
     59 
     60 y = cdf( 8.0, 8.0 );
     61 // returns 1.0
     62 
     63 y = cdf( 10.0, 8.0 );
     64 // returns 1.0
     65 ```
     66 
     67 #### cdf.factory( mu )
     68 
     69 Returns a function for evaluating the [cumulative distribution function][cdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     70 
     71 ```javascript
     72 var mycdf = cdf.factory( 10.0 );
     73 
     74 var y = mycdf( 10.0 );
     75 // returns 1.0
     76 
     77 y = mycdf( 8.0 );
     78 // returns 0.0
     79 ```
     80 
     81 </section>
     82 
     83 <!-- /.usage -->
     84 
     85 <section class="examples">
     86 
     87 ## Examples
     88 
     89 <!-- eslint no-undef: "error" -->
     90 
     91 ```javascript
     92 var randu = require( '@stdlib/random/base/randu' );
     93 var round = require( '@stdlib/math/base/special/round' );
     94 var cdf = require( '@stdlib/stats/base/dists/degenerate/cdf' );
     95 
     96 var mu;
     97 var x;
     98 var y;
     99 var i;
    100 
    101 for ( i = 0; i < 100; i++ ) {
    102     x = round( randu()*10.0 );
    103     mu = round( randu()*10.0 );
    104     y = cdf( x, mu );
    105     console.log( 'x: %d, µ: %d, F(x;µ): %d', x, mu, y );
    106 }
    107 ```
    108 
    109 </section>
    110 
    111 <!-- /.examples -->
    112 
    113 <section class="links">
    114 
    115 [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function
    116 
    117 [degenerate-distribution]: https://en.wikipedia.org/wiki/Degenerate_distribution
    118 
    119 </section>
    120 
    121 <!-- /.links -->