Chi-squared
Chi-squared distribution.
Usage
var chisquare = require( '@stdlib/stats/base/dists/chisquare' );
chisquare
Chi-squared distribution.
var dist = chisquare;
// returns {...}
The namespace contains the following distribution functions:
cdf( x, k )
: Chi-squared distribution cumulative distribution function.logpdf( x, k )
: evaluate the natural logarithm of the probability density function (PDF) for a chi-squared distribution.mgf( t, k )
: Chi-squared distribution moment-generating function (MGF).pdf( x, k )
: Chi-squared distribution probability density function (PDF).quantile( p, k )
: Chi-squared distribution quantile function.
The namespace contains the following functions for calculating distribution properties:
entropy( k )
: Chi-squared distribution differential entropy.kurtosis( k )
: Chi-squared distribution excess kurtosis.mean( k )
: Chi-squared distribution expected value.median( k )
: Chi-squared distribution median.mode( k )
: Chi-squared distribution mode.skewness( k )
: Chi-squared distribution skewness.stdev( k )
: Chi-squared distribution standard deviation.variance( k )
: Chi-squared distribution variance.
The namespace contains a constructor function for creating a Chi-squared distribution object.
ChiSquare( [k] )
: Chi-squared distribution constructor.
var ChiSquare = require( '@stdlib/stats/base/dists/chisquare' ).ChiSquare;
var dist = new ChiSquare( 4.0 );
var mu = dist.mean;
// returns 4.0
Examples
var roundn = require( '@stdlib/math/base/special/roundn' );
var chisquare = require( '@stdlib/stats/base/dists/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 ) );