diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/README.md b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/README.md index 25b2d04c7a72..cb6a3b486c3f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/README.md @@ -106,10 +106,43 @@ var y = dist.pmf( 4.0 ); ```javascript -var objectKeys = require( '@stdlib/utils/keys' ); var negativeBinomial = require( '@stdlib/stats/base/dists/negative-binomial' ); -console.log( objectKeys( negativeBinomial ) ); +/* +* Let's take an example of flipping a biased coin until getting 5 heads. +* This situation can be modeled using a Negative Binomial distribution with r = 5 and p = 1/2. +*/ + +var r = 5.0; +var p = 1/2; + +// Mean can be used to calculate the average number of trials needed to get 5 heads: +console.log( negativeBinomial.mean( r, p ) ); +// => 5 + +// PMF can be used to calculate the probability of getting heads on a specific trial (say on the 8th trial): +console.log( negativeBinomial.pmf( 8, r, p ) ); +// => ~0.06 + +// CDF can be used to calculate the probability up to a certain number of trials (say up to 8 trials): +console.log( negativeBinomial.cdf( 8, r, p ) ); +// => ~0.867 + +// Quantile can be used to calculate the number of trials at which you can be 80% confident that the actual number will not exceed: +console.log( negativeBinomial.quantile( 0.8, r, p ) ); +// => 7 + +// Standard deviation can be used to calculate the measure of the spread of trials around the mean: +console.log( negativeBinomial.stdev( r, p ) ); +// => ~3.162 + +// Skewness can be used to calculate the asymmetry of the distribution of trials: +console.log( negativeBinomial.skewness( r, p ) ); +// => ~0.949 + +// MGF can be used for more advanced statistical analyses and generating moments of the distribution: +console.log( negativeBinomial.mgf( 0.5, r, p ) ); +// => ~2277.597 ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/examples/index.js index b36b4b3f10de..15e63b0c6fd9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/examples/index.js @@ -18,7 +18,40 @@ 'use strict'; -var objectKeys = require( '@stdlib/utils/keys' ); var negativeBinomial = require( './../lib' ); -console.log( objectKeys( negativeBinomial ) ); +/* +* Let's take an example of flipping a biased coin until getting 5 heads. +* This situation can be modeled using a Negative Binomial distribution with r = 5 and p = 1/2. +*/ + +var r = 5.0; +var p = 1/2; + +// Mean can be used to calculate the average number of trials needed to get 5 heads: +console.log( negativeBinomial.mean( r, p ) ); +// => 5 + +// PMF can be used to calculate the probability of getting heads on a specific trial (say on the 8th trial): +console.log( negativeBinomial.pmf( 8, r, p ) ); +// => ~0.06 + +// CDF can be used to calculate the probability up to a certain number of trials (say up to 8 trials): +console.log( negativeBinomial.cdf( 8, r, p ) ); +// => ~0.867 + +// Quantile can be used to calculate the number of trials at which you can be 80% confident that the actual number will not exceed: +console.log( negativeBinomial.quantile( 0.8, r, p ) ); +// => 7 + +// Standard deviation can be used to calculate the measure of the spread of trials around the mean: +console.log( negativeBinomial.stdev( r, p ) ); +// => ~3.162 + +// Skewness can be used to calculate the asymmetry of the distribution of trials: +console.log( negativeBinomial.skewness( r, p ) ); +// => ~0.949 + +// MGF can be used for more advanced statistical analyses and generating moments of the distribution: +console.log( negativeBinomial.mgf( 0.5, r, p ) ); +// => ~2277.597