Skip to content

Commit

Permalink
docs: improve examples of stats/base/dists/chisquare namespace
Browse files Browse the repository at this point in the history
PR-URL: #2678
Closes: #1619

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
  • Loading branch information
kohantikanath and Planeshifter authored Nov 17, 2024
1 parent 1983295 commit 28bdda3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
30 changes: 28 additions & 2 deletions lib/node_modules/@stdlib/stats/base/dists/chisquare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,36 @@ var mu = dist.mean;
<!-- eslint no-undef: "error" -->

```javascript
var objectKeys = require( '@stdlib/utils/keys' );
var roundn = require( '@stdlib/math/base/special/roundn' );
var chisquare = require( '@stdlib/stats/base/dists/chisquare' );

console.log( objectKeys( chisquare ) );
// Define degrees of freedom:
var k = 5.0;

// Calculate distribution properties:
console.log( 'Mean: %d', chisquare.mean( k ) );
console.log( 'Median: %d', roundn( chisquare.median( k ), -4 ) );
console.log( 'Mode: %d', chisquare.mode( k ) );
console.log( 'Variance: %d', chisquare.variance( k ) );
console.log( 'Standard Deviation: %d', roundn( chisquare.stdev( k ), -4 ) );
console.log( 'Skewness: %d', roundn( chisquare.skewness( k ), -4 ) );
console.log( 'Excess Kurtosis: %d', roundn( chisquare.kurtosis( k ), -4 ) );
console.log( 'Entropy: %d', roundn( chisquare.entropy( k ), -4 ) );

// Evaluate probability functions:
var x = 3.0;
console.log( '\nEvaluating at x = %d', x );
console.log( 'PDF: %d', roundn( chisquare.pdf( x, k ), -4 ) );
console.log( 'logPDF: %d', roundn( chisquare.logpdf( x, k ), -4 ) );
console.log( 'CDF: %d', roundn( chisquare.cdf( x, k ), -4 ) );

// Calculate quantiles:
var p = 0.7;
console.log( '\nQuantile at p = %d: %d', p, roundn( chisquare.quantile( p, k ), -4 ) );

// Evaluate moment-generating function:
var t = 0.1;
console.log( 'MGF at t = %d: %d', t, roundn( chisquare.mgf( t, k ), -4 ) );
```

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

'use strict';

var objectKeys = require( '@stdlib/utils/keys' );
var roundn = require( '@stdlib/math/base/special/roundn' );
var chisquare = require( './../lib' );

console.log( objectKeys( chisquare ) );
// Define degrees of freedom:
var k = 5.0;

// Calculate distribution properties:
console.log( 'Mean: %d', chisquare.mean( k ) );
console.log( 'Median: %d', roundn( chisquare.median( k ), -4 ) );
console.log( 'Mode: %d', chisquare.mode( k ) );
console.log( 'Variance: %d', chisquare.variance( k ) );
console.log( 'Standard Deviation: %d', roundn( chisquare.stdev( k ), -4 ) );
console.log( 'Skewness: %d', roundn( chisquare.skewness( k ), -4 ) );
console.log( 'Excess Kurtosis: %d', roundn( chisquare.kurtosis( k ), -4 ) );
console.log( 'Entropy: %d', roundn( chisquare.entropy( k ), -4 ) );

// Evaluate probability functions:
var x = 3.0;
console.log( '\nEvaluating at x = %d', x );
console.log( 'PDF: %d', roundn( chisquare.pdf( x, k ), -4 ) );
console.log( 'logPDF: %d', roundn( chisquare.logpdf( x, k ), -4 ) );
console.log( 'CDF: %d', roundn( chisquare.cdf( x, k ), -4 ) );

// Calculate quantiles:
var p = 0.7;
console.log( '\nQuantile at p = %d: %d', p, roundn( chisquare.quantile( p, k ), -4 ) );

// Evaluate moment-generating function:
var t = 0.1;
console.log( 'MGF at t = %d: %d', t, roundn( chisquare.mgf( t, k ), -4 ) );

1 comment on commit 28bdda3

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/chisquare $\color{green}168/168$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}168/168$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.