@stdlib/stats-base-dists-cauchy-cdf
v0.3.1
Published
Cauchy distribution cumulative distribution function (CDF).
Readme
Cumulative Distribution Function
Cauchy distribution cumulative distribution function.
The cumulative distribution function for a Cauchy random variable is
where x0 is the location parameter and gamma > 0 is the scale parameter.
Installation
npm install @stdlib/stats-base-dists-cauchy-cdfUsage
var cdf = require( '@stdlib/stats-base-dists-cauchy-cdf' );cdf( x, x0, gamma )
Evaluates the cumulative distribution function (CDF) for a Cauchy distribution with parameters x0 (location parameter) and gamma > 0 (scale parameter).
var y = cdf( 4.0, 0.0, 2.0 );
// returns ~0.852
y = cdf( 1.0, 0.0, 2.0 );
// returns ~0.648
y = cdf( 1.0, 3.0, 2.0 );
// returns 0.25If provided NaN as any argument, the function returns NaN.
var y = cdf( NaN, 0.0, 2.0 );
// returns NaN
y = cdf( 1.0, 2.0, NaN );
// returns NaN
y = cdf( 1.0, NaN, 3.0 );
// returns NaNIf provided gamma <= 0, the function returns NaN.
var y = cdf( 2.0, 0.0, -1.0 );
// returns NaN
y = cdf( 2.0, 0.0, 0.0 );
// returns NaNcdf.factory( x0, gamma )
Returns a function for evaluating the cumulative distribution function of a Cauchy distribution with parameters x0 (location parameter) and gamma > 0 (scale parameter).
var mycdf = cdf.factory( 10.0, 2.0 );
var y = mycdf( 10.0 );
// returns 0.5
y = mycdf( 12.0 );
// returns 0.75Examples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var EPS = require( '@stdlib/constants-float64-eps' );
var cdf = require( '@stdlib/stats-base-dists-cauchy-cdf' );
var opts = {
'dtype': 'float64'
};
var gamma = uniform( 10, EPS, 10.0, opts );
var x0 = uniform( 10, 0.0, 10.0, opts );
var x = uniform( 10, 0.0, 10.0, opts );
logEachMap( 'x: %0.4f, x0: %0.4f, γ: %0.4f, F(x;x0,γ): %0.4f', x, x0, gamma, cdf );C APIs
Usage
#include "stdlib/stats/base/dists/cauchy/cdf.h"stdlib_base_dists_cauchy_cdf( x, x0, gamma )
Evaluates the cumulative distribution function (CDF) for a Cauchy distribution with parameters x0 (location parameter) and gamma > 0 (scale parameter).
double out = stdlib_base_dists_cauchy_cdf( 4.0, 0.0, 2.0 );
// returns ~0.852The function accepts the following arguments:
- x:
[in] doubleinput value. - x0:
[in] doublelocation parameter. - gamma:
[in] doublescale parameter.
double stdlib_base_dists_cauchy_cdf( const double x, const double x0, const double gamma );Examples
#include "stdlib/stats/base/dists/cauchy/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 gamma;
double x0;
double y;
double x;
int i;
for ( i = 0; i < 25; i++ ) {
x = random_uniform( 0.0, 10.0 );
x0 = random_uniform( 0.0, 10.0 );
gamma = random_uniform( 0.0, 10.0 );
y = stdlib_base_dists_cauchy_cdf( x, x0, gamma );
printf( "x: %lf, k: %lf, γ: %lf, F(x;x0,γ): %lf\n", x, x0, gamma, y );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
