Skip to content

Commit d66f5d6

Browse files
docs: improve README examples of stats/base/dists/poisson namespace
PR-URL: stdlib-js#1734 Closes: stdlib-js#1641 --------- Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com> Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 6576490 commit d66f5d6

2 files changed

Lines changed: 68 additions & 4 deletions

File tree

lib/node_modules/@stdlib/stats/base/dists/poisson/README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,42 @@ y = dist.pmf( 2.3 );
111111
<!-- eslint no-undef: "error" -->
112112

113113
```javascript
114-
var objectKeys = require( '@stdlib/utils/keys' );
115114
var poisson = require( '@stdlib/stats/base/dists/poisson' );
116115

117-
console.log( objectKeys( poisson ) );
116+
/*
117+
* Let's take a customer service center example: average rate of customer inquiries is 3 per hour.
118+
* This situation can be modeled using a Poisson distribution with λ = 3
119+
*/
120+
121+
var lambda = 3;
122+
123+
// Mean can be used to calculate the average number of inquiries per hour:
124+
console.log( poisson.mean( lambda ) );
125+
// => 3
126+
127+
// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean:
128+
console.log( poisson.stdev( lambda ) );
129+
// => ~1.7321
130+
131+
// Variance can be used to calculate the variability of the number of inquiries:
132+
console.log( poisson.variance( lambda ) );
133+
// => 3
134+
135+
// PMF can be used to calculate specific number of inquiries in an hour:
136+
console.log( poisson.pmf( 4, lambda ) );
137+
// => ~0.1680
138+
139+
// CDF can be used to calculate probability upto certain number of inquiries in an hour:
140+
console.log( poisson.cdf( 2, lambda ) );
141+
// => ~0.4232
142+
143+
// Quantile can be used to calculate the number of inquiries at which you can be 80% confident that the actual number will not exceed.
144+
console.log( poisson.quantile( 0.8, lambda ) );
145+
// => 4
146+
147+
// MGF can be used for more advanced statistical analyses and generating moments of the distribution.
148+
console.log( poisson.mgf( 1.0, lambda ) );
149+
// => ~173.2690
118150
```
119151

120152
</section>

lib/node_modules/@stdlib/stats/base/dists/poisson/examples/index.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,39 @@
1818

1919
'use strict';
2020

21-
var objectKeys = require( '@stdlib/utils/keys' );
2221
var poisson = require( './../lib' );
2322

24-
console.log( objectKeys( poisson ) );
23+
/*
24+
* Let's take a customer service center example: average rate of customer inquiries is 3 per hour.
25+
* This situation can be modeled using a Poisson distribution with λ = 3
26+
*/
27+
28+
var lambda = 3;
29+
30+
// Mean can be used to calculate the average number of inquiries per hour:
31+
console.log( poisson.mean( lambda ) );
32+
// => 3
33+
34+
// Standard deviation can be used to calculate the measure of the spread of inquiries around the mean:
35+
console.log( poisson.stdev( lambda ) );
36+
// => ~1.7321
37+
38+
// Variance can be used to calculate the variability of the number of inquiries:
39+
console.log( poisson.variance( lambda ) );
40+
// => 3
41+
42+
// PMF can be used to calculate specific number of inquiries in an hour:
43+
console.log( poisson.pmf( 4, lambda ) );
44+
// => ~0.1680
45+
46+
// CDF can be used to calculate probability upto certain number of inquiries in an hour:
47+
console.log( poisson.cdf( 2, lambda ) );
48+
// => ~0.4232
49+
50+
// Quantile can be used to calculate the number of inquiries at which you can be 80% confident that the actual number will not exceed.
51+
console.log( poisson.quantile( 0.8, lambda ) );
52+
// => 4
53+
54+
// MGF can be used for more advanced statistical analyses and generating moments of the distribution.
55+
console.log( poisson.mgf( 1.0, lambda ) );
56+
// => ~173.2690

0 commit comments

Comments
 (0)