Fréchet distribution probability density function.
The probability density function for a Fréchet random variable is
where alpha > 0 is the shape, s > 0 the scale and m the location parameter.
var pdf = require( '@stdlib/stats/base/dists/frechet/pdf' );Evaluates the probability density function (PDF) for a Fréchet distribution with shape alpha, scale s, and location m at a value x.
var y = pdf( 10.0, 2.0, 3.0, 5.0 );
// returns ~0.1
y = pdf( -3.0, 1.0, 2.0, -4.0 );
// returns ~0.271
y = pdf( 0.0, 2.0, 1.0, -1.0 );
// returns ~0.736If provided x <= m, the function returns 0.
var y = pdf( -2.0, 2.0, 1.0, -1.0 );
// returns 0.0If provided NaN as any argument, the function returns NaN.
var y = pdf( NaN, 1.0, 1.0, 0.0 );
// returns NaN
y = pdf( 0.0, NaN, 1.0, 0.0 );
// returns NaN
y = pdf( 0.0, 1.0, NaN, 0.0);
// returns NaN
y = pdf( 0.0, 1.0, 1.0, NaN );
// returns NaNIf provided alpha <= 0, the function returns NaN.
var y = pdf( 2.0, -0.1, 1.0, 1.0 );
// returns NaN
y = pdf( 2.0, 0.0, 1.0, 1.0 );
// returns NaNIf provided s <= 0, the function returns NaN.
var y = pdf( 2.0, 1.0, -1.0, 1.0 );
// returns NaN
y = pdf( 2.0, 1.0, 0.0, 1.0 );
// returns NaNReturns a function for evaluating the probability density function of a Fréchet distribution with shape alpha, scale s, and location m.
var mypdf = pdf.factory( 3.0, 3.0, 5.0 );
var y = mypdf( 10.0 );
// returns ~0.104
y = mypdf( 7.0 );
// returns ~0.173var randu = require( '@stdlib/random/base/randu' );
var pdf = require( '@stdlib/stats/base/dists/frechet/pdf' );
var alpha;
var m;
var s;
var x;
var y;
var i;
for ( i = 0; i < 100; i++ ) {
alpha = randu() * 10.0;
x = randu() * 10.0;
s = randu() * 10.0;
m = randu() * 10.0;
y = pdf( x, alpha, s, m );
console.log( 'x: %d, α: %d, s: %d, m: %d, f(x;α,s,m): %d', x.toFixed( 4 ), alpha.toFixed( 4 ), s.toFixed( 4 ), m.toFixed( 4 ), y.toFixed( 4 ) );
}#include "stdlib/stats/base/dists/frechet/pdf.h"Evaluates the probability density function (PDF) for a Fréchet distribution with shape alpha, scale s, and location m at a value x.
double y = stdlib_base_dists_frechet_pdf( 10.0, 2.0, 3.0, 2.0 );
// returns ~0.031The function accepts the following arguments:
- x:
[in] doubleinput value. - alpha:
[in] doubleshape parameter. - s:
[in] doublescale parameter. - m:
[in] doublelocation parameter.
double stdlib_base_dists_frechet_pdf( const double x, const double alpha, const double s, const double m );#include "stdlib/stats/base/dists/frechet/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 alpha;
double x;
double s;
double m;
double y;
int i;
for ( i = 0; i < 10; i++ ) {
x = random_uniform( 0.0, 10.0 );
alpha = random_uniform( 0.0, 10.0 );
s = random_uniform( 0.0, 10.0 );
m = random_uniform( 0.0, 10.0 );
y = stdlib_base_dists_frechet_pdf( x, alpha, s, m );
printf( "x: %lf, α: %lf, s: %lf, m: %lf, f(x;α,s,m): %lf\n", x, alpha, s, m, y );
}
}