time-to-botec

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

README.md (3732B)


      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 Density Function
     22 
     23 > [Degenerate distribution][degenerate-distribution] [probability density function][pdf] (PDF).
     24 
     25 <section class="intro">
     26 
     27 Strictly speaking, as a discrete distribution, a [degenerate][degenerate-distribution] has no [probability density function][pdf] (PDF). Extending the notion of a [PDF][pdf], we conceptualize the [PDF][pdf] of a [degenerate][degenerate-distribution] as an infinitely tall spike centered at `mu`. More formally,
     28 
     29 <!-- <equation class="equation" label="eq:degenerate_pdf" align="center" raw="f(x;\mu) = \delta(x-\mu)" alt="Probability density function (PDF) for a degenerate distribution."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="f(x;\mu) = \delta(x-\mu)" data-equation="eq:degenerate_pdf">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/degenerate/pdf/docs/img/equation_degenerate_pdf.svg" alt="Probability density function (PDF) for a degenerate distribution.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 where `delta` is the Dirac delta function.
     39 
     40 <!-- <equation class="equation" label="eq:dirac_delta" align="center" raw="\delta(x) = {\begin{cases}+\infty, & x = 0\\0, & x \neq 0\end{cases}}" alt="Dirac delta function."> -->
     41 
     42 <div class="equation" align="center" data-raw-text="\delta(x) = {\begin{cases}+\infty, &amp; x = 0\\0, &amp; x \neq 0\end{cases}}" data-equation="eq:dirac_delta">
     43     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/degenerate/pdf/docs/img/equation_dirac_delta.svg" alt="Dirac delta function.">
     44     <br>
     45 </div>
     46 
     47 <!-- </equation> -->
     48 
     49 </section>
     50 
     51 <!-- /.intro -->
     52 
     53 <section class="usage">
     54 
     55 ## Usage
     56 
     57 ```javascript
     58 var pdf = require( '@stdlib/stats/base/dists/degenerate/pdf' );
     59 ```
     60 
     61 #### pdf( x, mu )
     62 
     63 Evaluates the [PDF][pdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     64 
     65 ```javascript
     66 var y = pdf( 2.0, 8.0 );
     67 // returns 0.0
     68 
     69 y = pdf( 8.0, 8.0 );
     70 // returns Infinity
     71 ```
     72 
     73 #### pdf.factory( mu )
     74 
     75 Returns a function for evaluating the [PDF][pdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     76 
     77 ```javascript
     78 var mypdf = pdf.factory( 10.0 );
     79 
     80 var y = mypdf( 10.0 );
     81 // returns Infinity
     82 
     83 y = mypdf( 5.0 );
     84 // returns 0.0
     85 
     86 y = mypdf( 12.0 );
     87 // returns 0.0
     88 ```
     89 
     90 </section>
     91 
     92 <!-- /.usage -->
     93 
     94 <section class="examples">
     95 
     96 ## Examples
     97 
     98 <!-- eslint no-undef: "error" -->
     99 
    100 ```javascript
    101 var randu = require( '@stdlib/random/base/randu' );
    102 var round = require( '@stdlib/math/base/special/round' );
    103 var pdf = require( '@stdlib/stats/base/dists/degenerate/pdf' );
    104 
    105 var mu;
    106 var x;
    107 var y;
    108 var i;
    109 
    110 for ( i = 0; i < 100; i++ ) {
    111     x = round( randu()*5.0 );
    112     mu = round( randu()*5.0 );
    113     y = pdf( x, mu );
    114     console.log( 'x: %d, µ: %d, f(x;µ): %d', x, mu, y );
    115 }
    116 ```
    117 
    118 </section>
    119 
    120 <!-- /.examples -->
    121 
    122 <section class="links">
    123 
    124 [pdf]: https://en.wikipedia.org/wiki/Probability_density_function
    125 
    126 [degenerate-distribution]: https://en.wikipedia.org/wiki/Degenerate_distribution
    127 
    128 </section>
    129 
    130 <!-- /.links -->