@stdlib/stats-base-dists-pareto-type1-logcdf
v0.2.1
Published
Natural logarithm of the cumulative distribution function (CDF)for a Pareto (Type I) distribution.
Downloads
126
Readme
Logarithm of Cumulative Distribution Function
Evaluate the natural logarithm of the cumulative distribution function for a Pareto (Type I) distribution.
The cumulative distribution function for a Pareto (Type I) random variable is
and zero otherwise. In the equation, alpha > 0 is the shape parameter and beta > 0 is the scale parameter.
Installation
npm install @stdlib/stats-base-dists-pareto-type1-logcdfUsage
var logcdf = require( '@stdlib/stats-base-dists-pareto-type1-logcdf' );logcdf( x, alpha, beta )
Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Pareto (Type I) distribution with parameters alpha (shape parameter) and beta (scale parameter).
var y = logcdf( 2.0, 1.0, 1.0 );
// returns ~-0.693
y = logcdf( 5.0, 2.0, 4.0 );
// returns ~-1.022
y = logcdf( 4.0, 2.0, 2.0 );
// returns ~-0.288
y = logcdf( 1.9, 2.0, 2.0 );
// returns -Infinity
y = logcdf( +Infinity, 4.0, 2.0 );
// returns 0.0If provided NaN as any argument, the function returns NaN.
var y = logcdf( NaN, 1.0, 1.0 );
// returns NaN
y = logcdf( 0.0, NaN, 1.0 );
// returns NaN
y = logcdf( 0.0, 1.0, NaN );
// returns NaNIf provided alpha <= 0, the function returns NaN.
var y = logcdf( 2.0, -1.0, 0.5 );
// returns NaN
y = logcdf( 2.0, 0.0, 0.5 );
// returns NaNIf provided beta <= 0, the function returns NaN.
var y = logcdf( 2.0, 0.5, -1.0 );
// returns NaN
y = logcdf( 2.0, 0.5, 0.0 );
// returns NaNlogcdf.factory( alpha, beta )
Returns a function for evaluating the natural logarithm of the cumulative distribution function (CDF) of a Pareto (Type I) distribution with parameters alpha (shape parameter) and beta (scale parameter).
var mylogcdf = logcdf.factory( 10.0, 2.0 );
var y = mylogcdf( 3.0 );
// returns ~-0.017
y = mylogcdf( 2.5 );
// returns ~-0.114Notes
- In virtually all cases, using the
logpdforlogcdffunctions is preferable to manually computing the logarithm of thepdforcdf, respectively, since the latter is prone to overflow and underflow.
Examples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var logcdf = require( '@stdlib/stats-base-dists-pareto-type1-logcdf' );
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, 0.0, 5.0, opts );
var beta = uniform( 10, 0.0, 5.0, opts );
var x = uniform( 10, 0.0, 8.0, opts );
logEachMap( 'x: %0.4f, α: %0.4f, β: %0.4f, ln(F(x;α,β)): %0.4f', x, alpha, beta, logcdf );C APIs
Usage
#include "stdlib/stats/base/dists/pareto-type1/logcdf.h"stdlib_base_dists_pareto_type1_logcdf( x, alpha, beta )
Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Pareto (Type I) distribution with parameters alpha (shape parameter) and beta (scale parameter).
double y = stdlib_base_dists_pareto_type1_logcdf( 2.0, 1.0, 1.0 );
// returns ~-0.693The function accepts the following arguments:
- x:
[in] doubleinput value. - alpha:
[in] doubleshape parameter. - beta:
[in] doublescale parameter.
double stdlib_base_dists_pareto_type1_logcdf( const double x, const double alpha, const double beta );Examples
#include "stdlib/stats/base/dists/pareto-type1/logcdf.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 beta;
double x;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
x = random_uniform( 0.0, 8.0 );
alpha = random_uniform( 0.0, 5.0 );
beta = random_uniform( 0.0, 5.0 );
y = stdlib_base_dists_pareto_type1_logcdf( x, alpha, beta );
printf( "x: %lf, α: %lf, β: %lf, ln(F(x;α,β)): %lf\n", x, alpha, beta, 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.
