time-to-botec

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

README.md (2154B)


      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 # Probability Mass Function
     22 
     23 > [Degenerate distribution][degenerate-distribution] [probability mass function][pmf] (PMF).
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var pmf = require( '@stdlib/stats/base/dists/degenerate/pmf' );
     37 ```
     38 
     39 #### pmf( x, mu )
     40 
     41 Evaluates the [PMF][pmf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     42 
     43 ```javascript
     44 var y = pmf( 2.0, 8.0 );
     45 // returns 0.0
     46 
     47 y = pmf( 8.0, 8.0 );
     48 // returns 1.0
     49 ```
     50 
     51 #### pmf.factory( mu )
     52 
     53 Returns a function for evaluating the [PMF][pmf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     54 
     55 ```javascript
     56 var mypmf = pmf.factory( 10.0 );
     57 
     58 var y = mypmf( 10.0 );
     59 // returns 1.0
     60 
     61 y = mypmf( 5.0 );
     62 // returns 0.0
     63 
     64 y = mypmf( 12.0 );
     65 // returns 0.0
     66 ```
     67 
     68 </section>
     69 
     70 <!-- /.usage -->
     71 
     72 <section class="examples">
     73 
     74 ## Examples
     75 
     76 <!-- eslint no-undef: "error" -->
     77 
     78 ```javascript
     79 var randu = require( '@stdlib/random/base/randu' );
     80 var round = require( '@stdlib/math/base/special/round' );
     81 var pmf = require( '@stdlib/stats/base/dists/degenerate/pmf' );
     82 
     83 var mu;
     84 var x;
     85 var y;
     86 var i;
     87 
     88 for ( i = 0; i < 100; i++ ) {
     89     x = round( randu()*5.0 );
     90     mu = round( randu()*5.0 );
     91     y = pmf( x, mu );
     92     console.log( 'x: %d, µ: %d, P(X=x;µ): %d', x, mu, y );
     93 }
     94 ```
     95 
     96 </section>
     97 
     98 <!-- /.examples -->
     99 
    100 <section class="links">
    101 
    102 [pmf]: https://en.wikipedia.org/wiki/Probability_mass_function
    103 
    104 [degenerate-distribution]: https://en.wikipedia.org/wiki/Degenerate_distribution
    105 
    106 </section>
    107 
    108 <!-- /.links -->