Skip to content

Commit 452d183

Browse files
docs: improve README examples for stats/base/dists/rayleigh namespace
PR-URL: #1754 Closes: #1642 --------- Signed-off-by: Philipp Burckhardt <[email protected]> Co-authored-by: Philipp Burckhardt <[email protected]> Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 11dcefb commit 452d183

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,44 @@ var y = dist.pdf( 0.8 );
109109
<!-- eslint no-undef: "error" -->
110110

111111
```javascript
112-
var objectKeys = require( '@stdlib/utils/keys' );
113112
var rayleigh = require( '@stdlib/stats/base/dists/rayleigh' );
114113

115-
console.log( objectKeys( rayleigh ) );
114+
/*
115+
* The Rayleigh distribution can be used to model wind speeds.
116+
* Let's consider a scenario where we want to estimate various properties related to wind speeds.
117+
*/
118+
119+
// Set the Rayleigh distribution parameter (scale parameter):
120+
var s = 10.0;
121+
122+
// Calculate mean, variance, and standard deviation of the Rayleigh distribution:
123+
console.log( rayleigh.mean( s ) );
124+
// => ~12.533
125+
126+
console.log( rayleigh.variance( s ) );
127+
// => ~42.920
128+
129+
console.log( rayleigh.stdev( s ) );
130+
// => ~6.551
131+
132+
// Evaluate the Probability Density Function (PDF) for a specific wind speed:
133+
var w = 15.0;
134+
console.log( rayleigh.pdf( w, s ) );
135+
// => ~0.049
136+
137+
// Determine Cumulative Distribution Function (CDF) for wind speeds up to a certain value:
138+
var t = 15.0;
139+
console.log( rayleigh.cdf( t, s ) );
140+
// => ~0.675
141+
142+
// Calculate the probability of wind speeds exceeding the threshold:
143+
var p = 1.0 - rayleigh.cdf( t, s );
144+
console.log( 'Probability of wind speeds exceeding ' + t + ' m/s:', p );
145+
146+
// Find the wind speed at which there's a 70% chance it won't exceed using the Quantile function:
147+
var c = 0.7;
148+
console.log( rayleigh.quantile( c, s ) );
149+
// => ~15.518
116150
```
117151

118152
</section>

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

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

1919
'use strict';
2020

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

24-
console.log( objectKeys( rayleigh ) );
23+
/*
24+
* The Rayleigh distribution can be used to model wind speeds.
25+
* Let's consider a scenario where we want to estimate various properties related to wind speeds.
26+
*/
27+
28+
// Set the Rayleigh distribution parameter (scale parameter):
29+
var s = 10.0;
30+
31+
// Calculate mean, variance, and standard deviation of the Rayleigh distribution:
32+
console.log( rayleigh.mean( s ) );
33+
// => ~12.533
34+
35+
console.log( rayleigh.variance( s ) );
36+
// => ~42.920
37+
38+
console.log( rayleigh.stdev( s ) );
39+
// => ~6.551
40+
41+
// Evaluate the Probability Density Function (PDF) for a specific wind speed:
42+
var w = 15.0;
43+
console.log( rayleigh.pdf( w, s ) );
44+
// => ~0.049
45+
46+
// Determine Cumulative Distribution Function (CDF) for wind speeds up to a certain value:
47+
var t = 15.0;
48+
console.log( rayleigh.cdf( t, s ) );
49+
// => ~0.675
50+
51+
// Calculate the probability of wind speeds exceeding the threshold:
52+
var p = 1.0 - rayleigh.cdf( t, s );
53+
console.log( 'Probability of wind speeds exceeding ' + t + ' m/s:', p );
54+
55+
// Find the wind speed at which there's a 70% chance it won't exceed using the Quantile function:
56+
var c = 0.7;
57+
console.log( rayleigh.quantile( c, s ) );
58+
// => ~15.518

0 commit comments

Comments
 (0)