Skip to content

Commit

Permalink
docs: improve README examples for stats/base/dists/t namespace
Browse files Browse the repository at this point in the history
PR-URL: stdlib-js#1728
Closes: stdlib-js#1645 

Reviewed-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
  • Loading branch information
Jai0401 authored and nishant-s7 committed Mar 7, 2024
1 parent 0c87f3e commit f9a0a64
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
17 changes: 15 additions & 2 deletions lib/node_modules/@stdlib/stats/base/dists/t/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,23 @@ var y = dist.cdf( 0.5 );
<!-- eslint no-undef: "error" -->

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

console.log( objectKeys( t ) );
var dof = 3;
var x = 1.5;

// Evaluate the probability density function (PDF) at a specific value:
var res = t.pdf( x, dof );
console.log( 'PDF at x = ' + x + ': ' + res );

// Evaluate the cumulative distribution function (CDF) at a specific value:
res = t.cdf( x, dof );
console.log( 'CDF at x = ' + x + ': ' + res );

// Get the mean and variance of the t distribution:
var mu = t.mean( dof );
var v = t.variance( dof );
console.log( 'Mean: ' + mu + ', Variance: ' + v );
```

</section>
Expand Down
17 changes: 15 additions & 2 deletions lib/node_modules/@stdlib/stats/base/dists/t/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@

'use strict';

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

console.log( objectKeys( t ) );
var dof = 3;
var x = 1.5;

// Evaluate the probability density function (PDF) at a specific value:
var res = t.pdf( x, dof );
console.log( 'PDF at x = ' + x + ': ' + res );

// Evaluate the cumulative distribution function (CDF) at a specific value:
res = t.cdf( x, dof );
console.log( 'CDF at x = ' + x + ': ' + res );

// Get the mean and variance of the t distribution:
var mu = t.mean( dof );
var v = t.variance( dof );
console.log( 'Mean: ' + mu + ', Variance: ' + v );

0 comments on commit f9a0a64

Please sign in to comment.