diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/README.md index a0d1bfa31d89..5cb7796a953a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/README.md @@ -1,11 +1,10 @@ # Cumulative Distribution Function @@ -24,33 +22,22 @@ limitations under the License.
-The [cumulative distribution function][cdf] for a [geometric][geometric-distribution] random variable is - - +The [cumulative distribution function][cdf] for a [geometric][geometric-distribution] random variable is: ```math -F(x;p)= \begin{cases} 0 & \text{ for } x < 0 \\ 1-(1 - p)^{\left\lfloor x \right\rfloor+1} & \text{ otherwise} \end{cases} +F(x;p)= \begin{cases} 0 & \text{for } x < 0 \\ 1-(1 - p)^{\left\lfloor x \right\rfloor+1} & \text{otherwise} \end{cases} ``` - - - - where `0 <= p <= 1` is the success probability. `x` denotes the number of _failures_ before the first success.
- -
## Usage ```javascript -var cdf = require( '@stdlib/stats/base/dists/geometric/cdf' ); +var cdf = require('@stdlib/stats/base/dists/geometric/cdf'); ``` #### cdf( x, p ) @@ -87,7 +74,7 @@ y = cdf( 2.0, 1.5 ); #### cdf.factory( p ) -Returns a function for evaluating the [cumulative distribution function][cdf] of a [geometric][geometric-distribution] distribution with success probability `p` +Returns a function for evaluating the [cumulative distribution function][cdf] of a [geometric][geometric-distribution] distribution with success probability `p`. ```javascript var mycdf = cdf.factory( 0.5 ); @@ -100,17 +87,13 @@ y = mycdf( 1.0 );
- -
## Examples - - ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var cdf = require( '@stdlib/stats/base/dists/geometric/cdf' ); +var randu = require('@stdlib/random/base/randu'); +var cdf = require('@stdlib/stats/base/dists/geometric/cdf'); var p; var x; @@ -127,25 +110,18 @@ for ( i = 0; i < 10; i++ ) {
- - - - -* * * - -
- -## C APIs +
- +## References -
+- [Cumulative distribution function (Wikipedia)](https://en.wikipedia.org/wiki/Cumulative_distribution_function) +- [Geometric distribution (Wikipedia)](https://en.wikipedia.org/wiki/Geometric_distribution)
- +
- +## C APIs
@@ -164,29 +140,8 @@ double out = stdlib_base_dists_geometric_cdf( 2.0, 0.5 ); // returns 0.875 ``` -The function accepts the following arguments: - -- **x**: `[in] double` input value. -- **p**: `[in] double` probability of success. - -```c -double stdlib_base_dists_geometric_cdf( const double x, const double p ); -``` -
- - - - -
- -
- - - - -
### Examples @@ -199,7 +154,7 @@ double stdlib_base_dists_geometric_cdf( const double x, const double p ); static double random_uniform( const double min, const double max ) { double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); - return min + ( v*(max-min) ); + return min + ( v * (max - min) ); } int main( void ) { @@ -219,30 +174,16 @@ int main( void ) {
- - - - -
- -
- - - - - - - - - + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/src/main.c index 2a0355fa0957..3b8ae50902d7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/cdf/src/main.c @@ -27,7 +27,7 @@ * * @param x input value * @param p success probability -* @return evaluated CDF +* @return evaluated CDF or NaN (if input is invalid) * * @example * double y = stdlib_base_dists_geometric_cdf( 2.0, 0.5 ); @@ -50,3 +50,4 @@ double stdlib_base_dists_geometric_cdf( const double x, const double p ) { } return 1.0 - stdlib_base_pow( 1.0 - p, stdlib_base_floor( x ) + 1.0 ); } +