README.md (3198B)
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 Cumulative Distribution Function 22 23 > [Degenerate distribution][degenerate-distribution] logarithm of [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, & x \geq \mu,\\0, & x < \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/logcdf/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 logcdf = require( '@stdlib/stats/base/dists/degenerate/logcdf' ); 50 ``` 51 52 #### logcdf( x, mu ) 53 54 Evaluates the natural logarithm of the [CDF][cdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`. 55 56 ```javascript 57 var y = logcdf( 2.0, 8.0 ); 58 // returns -Infinity 59 60 y = logcdf( 8.0, 8.0 ); 61 // returns 0.0 62 63 y = logcdf( 10.0, 8.0 ); 64 // returns 0.0 65 ``` 66 67 #### logcdf.factory( mu ) 68 69 Returns a function for evaluating the natural logarithm of the [cumulative distribution function][cdf] of a [degenerate distribution][degenerate-distribution] centered at `mu`. 70 71 ```javascript 72 var mylogcdf = logcdf.factory( 10.0 ); 73 74 var y = mylogcdf( 10.0 ); 75 // returns 0.0 76 77 y = mylogcdf( 8.0 ); 78 // returns -Infinity 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 logcdf = require( '@stdlib/stats/base/dists/degenerate/logcdf' ); 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 = logcdf( x, mu ); 105 console.log( 'x: %d, µ: %d, ln(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 -->