Skip to content

Latest commit

 

History

History
234 lines (149 loc) · 5.29 KB

File metadata and controls

234 lines (149 loc) · 5.29 KB

Cumulative Distribution Function

Studentized range distribution cumulative distribution function (CDF).

Usage

var cdf = require( '@stdlib/stats/base/dists/studentized-range/cdf' );

cdf( x, r, v[, nranges=1] )

Evaluates the cumulative distribution function (CDF) for a studentized range distribution with sample size r and v degrees of freedom. Optionally, the number of groups whose maximum range is considered can be specified via the nranges parameter.

var y = cdf( 0.5, 3.0, 2.0 );
// returns ~0.0644

y = cdf( 12.1, 17.0, 2.0 );
// returns ~0.913

y = cdf( 0.5, 3.0, 2.0, 2 );
// returns ~0.01

If provided NaN as any argument, the function returns NaN.

var y = cdf( NaN, 2.0, 2.0 );
// returns NaN

y = cdf( 1.5, NaN, 2.0 );
// returns NaN

If provided v < 2 or r < 2, the function returns NaN.

var y = cdf( 2.0, -1.0, 3.0 );
// returns NaN

y = cdf( 2.0, 3.0, 1.5 );
// returns NaN

cdf.factory( r, v[, nranges=1] )

Returns a function for evaluating the cdf of a studentized range distribution with sample size r and v degrees of freedom. Optionally, the number of groups whose maximum range is considered can be specified via the nranges parameter.

var mycdf = cdf.factory( 3.0, 2.0 );
var y = mycdf( 3.0 );
// returns ~0.712

y = mycdf( 1.0 );
// returns ~0.216

Examples

var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var cdf = require( '@stdlib/stats/base/dists/studentized-range/cdf' );

var opts = {
    'dtype': 'float64'
};
var q = uniform( 10, 0.0, 12.0, opts );
var r = uniform( 10, 2.0, 20.0, opts );
var v = uniform( 10, 2.0, 10.0, opts );

logEachMap( 'q: %0.4f, r: %0.4f, v: %0.4f, F(x;v): %0.4f', q, r, v, cdf );

C APIs

Usage

#include "stdlib/stats/base/dists/studentized-range/cdf.h"

stdlib_base_dists_studentized_range_cdf( q, r, v, nranges )

Evaluates the cumulative distribution function (CDF) for a studentized range distribution.

double out = stdlib_base_dists_studentized_range_cdf( 0.5, 3.0, 2.0, 1.0 );
// returns ~0.0644

The function accepts the following arguments:

  • q: [in] double quantile of the studentized range.
  • r: [in] double sample size for range (same for each group).
  • v: [in] double degrees of freedom.
  • nranges: [in] double number of groups whose maximum range is considered.
double stdlib_base_dists_studentized_range_cdf( const double q, const double r, const double v, const double nranges );

Examples

#include "stdlib/stats/base/dists/studentized-range/cdf.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 q;
    double r;
    double v;
    double y;
    int i;

    for ( i = 0; i < 10; i++ ) {
        q = random_uniform( 0.0, 12.0 );
        r = random_uniform( 2.0, 20.0 );
        v = random_uniform( 2.0, 10.0 );
        y = stdlib_base_dists_studentized_range_cdf( q, r, v, 1.0 );
        printf( "q: %lf, r: %lf, v: %lf, F(x;v): %lf\n", q, r, v, y );
    }
}