time-to-botec

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

README.md (2326B)


      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 # Logarithm of Probability Mass Function
     22 
     23 > Evaluate the natural logarithm of the [probability mass function][pmf] (PMF) for a [degenerate distribution][degenerate-distribution].
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var logpmf = require( '@stdlib/stats/base/dists/degenerate/logpmf' );
     37 ```
     38 
     39 #### logpmf( x, mu )
     40 
     41 Evaluates the natural logarithm of the [PMF][pmf] for a [degenerate distribution][degenerate-distribution] centered at `mu`.
     42 
     43 ```javascript
     44 var y = logpmf( 2.0, 8.0 );
     45 // returns -Infinity
     46 
     47 y = logpmf( 8.0, 8.0 );
     48 // returns 0.0
     49 ```
     50 
     51 #### logpmf.factory( mu )
     52 
     53 Returns a function for evaluating the natural logarithm of the [PMF][pmf] of a [degenerate distribution][degenerate-distribution] centered at `mu`.
     54 
     55 ```javascript
     56 var mylogpmf = logpmf.factory( 10.0 );
     57 
     58 var y = mylogpmf( 10.0 );
     59 // returns 0.0
     60 
     61 y = mylogpmf( 5.0 );
     62 // returns -Infinity
     63 
     64 y = mylogpmf( 12.0 );
     65 // returns -Infinity
     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 logpmf = require( '@stdlib/stats/base/dists/degenerate/logpmf' );
     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 = logpmf( x, mu );
     92     console.log( 'x: %d, µ: %d, ln(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 -->