Skip to content

Latest commit

 

History

History
252 lines (157 loc) · 8.3 KB

README.md

File metadata and controls

252 lines (157 loc) · 8.3 KB
About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Logarithm of Cumulative Distribution Function

NPM version Build Status Coverage Status

Evaluate the logarithm of the cumulative distribution function Planck (discrete exponential) distribution.

The cumulative distribution function for a Planck random variable is

$$F(x;\lambda) = 1 - e^{-\lambda (\lfloor x \rfloor + 1)}$$

where λ is the shape parameter and x denotes the count of events in a quantized system.

Usage

import logcdf from 'https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-planck-logcdf@esm/index.mjs';

The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the tagged bundles. For example,

import logcdf from 'https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-planck-logcdf@v0.0.0-esm/index.mjs';

You can also import the following named exports from the package:

import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-planck-logcdf@esm/index.mjs';

logcdf( x, lambda )

Evaluates the logarithm of the cumulative distribution function for a Planck (discrete exponential) distribution with shape parameter lambda.

var y = logcdf( 2.0, 0.5 );
// returns ~-0.2525

y = logcdf( 2.0, 1.5 );
// returns ~-0.0112

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

var y = logcdf( NaN, 0.5 );
// returns NaN

y = logcdf( 0.0, NaN );
// returns NaN

If provided a shape parameter lambda which is nonpositive, the function returns NaN.

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

logcdf.factory( lambda )

Returns a function for evaluating the logarithm of the cumulative distribution function of a Planck (discrete exponential) distribution with shape parameter lambda.

var mylogcdf = logcdf.factory( 1.5 );
var y = mylogcdf( 3.0 );
// returns ~-0.0025

y = mylogcdf( 1.0 );
// returns ~-0.0511

Notes

  • In virtually all cases, using the logpmf or logcdf functions is preferable to manually computing the logarithm of the pmf or cdf, respectively, since the latter is prone to overflow and underflow.

Examples

<!DOCTYPE html>
<html lang="en">
<body>
<script type="module">

import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs';
import uniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-uniform@esm/index.mjs';
import logcdf from 'https://cdn.jsdelivr.net/gh/stdlib-js/stats-base-dists-planck-logcdf@esm/index.mjs';

var x = discreteUniform( 10, 0, 5 );
var lambda = uniform( 10, 0.1, 5.0 );

var y;
var i;
for ( i = 0; i < lambda.length; i++ ) {
    y = logcdf( x[ i ], lambda[ i ] );
    console.log( 'x: %d, λ: %d, ln(F(x;λ)): %d', x[ i ].toFixed( 4 ), lambda[ i ].toFixed( 4 ), y.toFixed( 4 ) );
}

</script>
</body>
</html>

Notice

This package is part of stdlib, a standard library 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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2025. The Stdlib Authors.