Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve README examples for stats/base/dists/rayleigh namespace #1754

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions lib/node_modules/@stdlib/stats/base/dists/rayleigh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,44 @@ var y = dist.pdf( 0.8 );
<!-- eslint no-undef: "error" -->

```javascript
var objectKeys = require( '@stdlib/utils/keys' );
var rayleigh = require( '@stdlib/stats/base/dists/rayleigh' );

console.log( objectKeys( rayleigh ) );
/*
* The Rayleigh distribution can be used to model wind speeds.
* Let's consider a scenario where we want to estimate various properties related to wind speeds.
*/

// Set the Rayleigh distribution parameter (scale parameter):
var s = 10.0;

// Calculate mean, variance, and standard deviation of the Rayleigh distribution:
console.log( rayleigh.mean( s ) );
// => ~12.533

console.log( rayleigh.variance( s ) );
// => ~42.920

console.log( rayleigh.stdev( s ) );
// => ~6.551

// Evaluate the Probability Density Function (PDF) for a specific wind speed:
var w = 15.0;
console.log( rayleigh.pdf( w, s ) );
// => ~0.049

// Determine Cumulative Distribution Function (CDF) for wind speeds up to a certain value:
var t = 15.0;
console.log( rayleigh.cdf( t, s ) );
// => ~0.675

// Calculate the probability of wind speeds exceeding the threshold:
var p = 1.0 - rayleigh.cdf( t, s );
console.log( 'Probability of wind speeds exceeding ' + t + ' m/s:', p );

// Find the wind speed at which there's a 70% chance it won't exceed using the Quantile function:
var c = 0.7;
console.log( rayleigh.quantile( c, s ) );
// => ~15.518
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,41 @@

'use strict';

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

console.log( objectKeys( rayleigh ) );
/*
* The Rayleigh distribution can be used to model wind speeds.
* Let's consider a scenario where we want to estimate various properties related to wind speeds.
*/

// Set the Rayleigh distribution parameter (scale parameter):
var s = 10.0;

// Calculate mean, variance, and standard deviation of the Rayleigh distribution:
console.log( rayleigh.mean( s ) );
// => ~12.533

console.log( rayleigh.variance( s ) );
// => ~42.920

console.log( rayleigh.stdev( s ) );
// => ~6.551

// Evaluate the Probability Density Function (PDF) for a specific wind speed:
var w = 15.0;
console.log( rayleigh.pdf( w, s ) );
// => ~0.049

// Determine Cumulative Distribution Function (CDF) for wind speeds up to a certain value:
var t = 15.0;
console.log( rayleigh.cdf( t, s ) );
// => ~0.675

// Calculate the probability of wind speeds exceeding the threshold:
var p = 1.0 - rayleigh.cdf( t, s );
console.log( 'Probability of wind speeds exceeding ' + t + ' m/s:', p );

// Find the wind speed at which there's a 70% chance it won't exceed using the Quantile function:
var c = 0.7;
console.log( rayleigh.quantile( c, s ) );
// => ~15.518
Loading