From 2cdce0d48faf8773d9af8ba2325de5280878c426 Mon Sep 17 00:00:00 2001 From: nishant-s7 Date: Wed, 6 Mar 2024 18:51:31 +0530 Subject: [PATCH 1/3] docs(examples): add examples to the documentation of poisson distribution Add examples to README file and examples/index.js file of poisson distribution. --- .../stats/base/dists/poisson/README.md | 36 +++++++++++++++++-- .../base/dists/poisson/examples/index.js | 36 +++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md b/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md index eee4ecf6770a..de2011d25bd1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md @@ -111,10 +111,42 @@ y = dist.pmf( 2.3 ); ```javascript -var objectKeys = require( '@stdlib/utils/keys' ); var poisson = require( '@stdlib/stats/base/dists/poisson' ); -console.log( objectKeys( poisson ) ); +/* +* Let's take a customer service center example: average rate of customer inquiries is 3 per hour +* This situation can be modeled using a Poisson distribution with λ = 3 +*/ + +var lambda = 3; + +// Mean can be used to calculate the average number of inquiries per hour +console.log( poisson.mean( lambda ) ); +// => 3 + +// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean +console.log( poisson.stdev( lambda ) ); +// => ~ 1.7321 + +// Variance can be used to calculate the variability of the number of inquiries +console.log( poisson.variance( lambda ) ); +// => 3 + +// PMF can be used to calculate specific number of inquiries in an hour +console.log( poisson.pmf( 4, lambda ) ); +// => ~ 0.1680 + +// CDF can be used to calculate probability upto certain number of inquiries in an hour +console.log( poisson.cdf( 2, lambda ) ); +// => ~ 0.4232 + +// Quantile can be used to calculate the number of inquiries at which you can be 80% confident that the actual number will not exceed. +console.log( poisson.quantile( 0.8, lambda ) ); +// => 4 + +// MGF can be used for more advanced statistical analyses and generating moments of the distribution. +console.log( poisson.mgf( 1.0, lambda ) ); +// => ~ 173.2690 ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js index e382436ef33a..01c3972fa1d9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js @@ -18,7 +18,39 @@ 'use strict'; -var objectKeys = require( '@stdlib/utils/keys' ); var poisson = require( './../lib' ); -console.log( objectKeys( poisson ) ); +/* +* Let's take a customer service center example: average rate of customer inquiries is 3 per hour +* This situation can be modeled using a Poisson distribution with λ = 3 +*/ + +var lambda = 3; + +// Mean can be used to calculate the average number of inquiries per hour +console.log( poisson.mean( lambda ) ); +// => 3 + +// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean +console.log( poisson.stdev( lambda ) ); +// => ~ 1.7321 + +// Variance can be used to calculate the variability of the number of inquiries +console.log( poisson.variance( lambda ) ); +// => 3 + +// PMF can be used to calculate specific number of inquiries in an hour +console.log( poisson.pmf( 4, lambda ) ); +// => ~ 0.1680 + +// CDF can be used to calculate probability upto certain number of inquiries in an hour +console.log( poisson.cdf( 2, lambda ) ); +// => ~ 0.4232 + +// Quantile can be used to calculate the number of inquiries at which you can be 80% confident that the actual number will not exceed. +console.log( poisson.quantile( 0.8, lambda ) ); +// => 4 + +// MGF can be used for more advanced statistical analyses and generating moments of the distribution. +console.log( poisson.mgf( 1.0, lambda ) ); +// => ~ 173.2690 From 55d0acfcc282e8310a29741c43cd930d7f46b054 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 6 Mar 2024 20:55:43 -0500 Subject: [PATCH 2/3] Apply suggestions from code review Signed-off-by: Philipp Burckhardt --- .../stats/base/dists/poisson/README.md | 18 ++++++++--------- .../base/dists/poisson/examples/index.js | 20 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md b/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md index de2011d25bd1..0679b6959e9d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md @@ -114,31 +114,31 @@ y = dist.pmf( 2.3 ); var poisson = require( '@stdlib/stats/base/dists/poisson' ); /* -* Let's take a customer service center example: average rate of customer inquiries is 3 per hour +* Let's take a customer service center example: average rate of customer inquiries is 3 per hour. * This situation can be modeled using a Poisson distribution with λ = 3 */ var lambda = 3; -// Mean can be used to calculate the average number of inquiries per hour +// Mean can be used to calculate the average number of inquiries per hour: console.log( poisson.mean( lambda ) ); // => 3 -// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean +// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean: console.log( poisson.stdev( lambda ) ); -// => ~ 1.7321 +// => ~1.7321 -// Variance can be used to calculate the variability of the number of inquiries +// Variance can be used to calculate the variability of the number of inquiries: console.log( poisson.variance( lambda ) ); // => 3 -// PMF can be used to calculate specific number of inquiries in an hour +// PMF can be used to calculate specific number of inquiries in an hour: console.log( poisson.pmf( 4, lambda ) ); -// => ~ 0.1680 +// => ~0.1680 // CDF can be used to calculate probability upto certain number of inquiries in an hour console.log( poisson.cdf( 2, lambda ) ); -// => ~ 0.4232 +// => ~0.4232 // Quantile can be used to calculate the number of inquiries at which you can be 80% confident that the actual number will not exceed. console.log( poisson.quantile( 0.8, lambda ) ); @@ -146,7 +146,7 @@ console.log( poisson.quantile( 0.8, lambda ) ); // MGF can be used for more advanced statistical analyses and generating moments of the distribution. console.log( poisson.mgf( 1.0, lambda ) ); -// => ~ 173.2690 +// => ~173.2690 ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js index 01c3972fa1d9..645008c52358 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js @@ -21,31 +21,31 @@ var poisson = require( './../lib' ); /* -* Let's take a customer service center example: average rate of customer inquiries is 3 per hour +* Let's take a customer service center example: average rate of customer inquiries is 3 per hour. * This situation can be modeled using a Poisson distribution with λ = 3 */ var lambda = 3; -// Mean can be used to calculate the average number of inquiries per hour +// Mean can be used to calculate the average number of inquiries per hour: console.log( poisson.mean( lambda ) ); // => 3 -// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean +// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean: console.log( poisson.stdev( lambda ) ); -// => ~ 1.7321 +// => ~1.7321 -// Variance can be used to calculate the variability of the number of inquiries +// Variance can be used to calculate the variability of the number of inquiries: console.log( poisson.variance( lambda ) ); // => 3 -// PMF can be used to calculate specific number of inquiries in an hour +// PMF can be used to calculate specific number of inquiries in an hour: console.log( poisson.pmf( 4, lambda ) ); -// => ~ 0.1680 +// => ~0.1680 -// CDF can be used to calculate probability upto certain number of inquiries in an hour +// CDF can be used to calculate probability upto certain number of inquiries in an hour: console.log( poisson.cdf( 2, lambda ) ); -// => ~ 0.4232 +// => ~0.4232 // Quantile can be used to calculate the number of inquiries at which you can be 80% confident that the actual number will not exceed. console.log( poisson.quantile( 0.8, lambda ) ); @@ -53,4 +53,4 @@ console.log( poisson.quantile( 0.8, lambda ) ); // MGF can be used for more advanced statistical analyses and generating moments of the distribution. console.log( poisson.mgf( 1.0, lambda ) ); -// => ~ 173.2690 +// => ~173.2690 From 3ce6a63698a77eb2cee0f9a612fa95bef766a53f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 6 Mar 2024 20:56:29 -0500 Subject: [PATCH 3/3] Update lib/node_modules/@stdlib/stats/base/dists/poisson/README.md Signed-off-by: Philipp Burckhardt --- lib/node_modules/@stdlib/stats/base/dists/poisson/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md b/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md index 0679b6959e9d..f8cae2dacec0 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/README.md @@ -136,7 +136,7 @@ console.log( poisson.variance( lambda ) ); console.log( poisson.pmf( 4, lambda ) ); // => ~0.1680 -// CDF can be used to calculate probability upto certain number of inquiries in an hour +// CDF can be used to calculate probability upto certain number of inquiries in an hour: console.log( poisson.cdf( 2, lambda ) ); // => ~0.4232