F distribution probability density function (PDF).
The probability density function (PDF) for a F random variable is
where d1 is the numerator degrees of freedom and d2 is the denominator degrees of freedom and B is the Beta function.
var pdf = require( '@stdlib/stats/base/dists/f/pdf' );Evaluates the probability density function (PDF) for a F distribution with parameters d1 (numerator degrees of freedom) and d2 (denominator degrees of freedom).
var y = pdf( 2.0, 0.5, 1.0 );
// returns ~0.057
y = pdf( 0.1, 1.0, 1.0 );
// returns ~0.915
y = pdf( -1.0, 4.0, 2.0 );
// returns 0.0If provided NaN as any argument, the function returns NaN.
var y = pdf( NaN, 1.0, 1.0 );
// returns NaN
y = pdf( 0.0, NaN, 1.0 );
// returns NaN
y = pdf( 0.0, 1.0, NaN );
// returns NaNIf provided d1 <= 0, the function returns NaN.
var y = pdf( 2.0, 0.0, 1.0 );
// returns NaN
y = pdf( 2.0, -1.0, 1.0 );
// returns NaNIf provided d2 <= 0, the function returns NaN.
var y = pdf( 2.0, 1.0, 0.0 );
// returns NaN
y = pdf( 2.0, 1.0, -1.0 );
// returns NaNReturns a function for evaluating the PDF of an F distribution with parameters d1 (numerator degrees of freedom) and d2 (denominator degrees of freedom).
var mypdf = pdf.factory( 6.0, 7.0 );
var y = mypdf( 7.0 );
// returns ~0.004
y = mypdf( 2.0 );
// returns ~0.166var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var pdf = require( '@stdlib/stats/base/dists/f/pdf' );
var opts = {
'dtype': 'float64'
};
var x = uniform( 10, 0.0, 4.0, opts );
var d1 = uniform( 10, 0.0, 10.0, opts );
var d2 = uniform( 10, 0.0, 10.0, opts );
logEachMap( 'x: %0.4f, d1: %0.4f, d2: %0.4f, f(x;d1,d2): %0.4f', x, d1, d2, pdf );#include "stdlib/stats/base/dists/f/pdf.h"Evaluates the probability density function (PDF) for an F distribution with numerator degrees of freedom d1 and denominator degrees of freedom d2.
double out = stdlib_base_dists_f_pdf( 2.0, 1.0, 1.0 );
// returns ~0.127The function accepts the following arguments:
- x:
[in] doubleinput value. - d1:
[in] doublenumerator degrees of freedom. - d2:
[in] doubledenominator degrees of freedom.
double stdlib_base_dists_f_pdf( const double x, const double d1, const double d2 );#include "stdlib/stats/base/dists/f/pdf.h"
#include <stdlib.h>
#include <stdio.h>
static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v*(max-min) );
}
int main( void ) {
double d1;
double d2;
double x;
double y;
int i;
for ( i = 0; i < 10; i++ ) {
x = random_uniform( 0.0, 10.0 );
d1 = random_uniform( 1.0, 10.0 );
d2 = random_uniform( 1.0, 10.0 );
y = stdlib_base_dists_f_pdf( x, d1, d2 );
printf( "x: %.4f, d1: %.4f, d2: %.4f, f(x;d1,d2): %.4f\n", x, d1, d2, y );
}
}