Skip to content

Commit

Permalink
chore: clean-up
Browse files Browse the repository at this point in the history
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: missing_dependencies
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
  • Loading branch information
kgryte committed Dec 27, 2024
1 parent c3cc291 commit c197355
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 23 deletions.
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/stats/base/dists/planck/cdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# Cumulative Distribution Function

> Planck distribution [cumulative distribution function][cdf].
> Planck (discrete exponential) distribution [cumulative distribution function][cdf].
<section class="intro">

Expand All @@ -34,7 +34,7 @@ F(x;\lambda) = 1 - e^{-\lambda (\lfloor x \rfloor + 1)}

<!-- </equation> -->

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

</section>

Expand All @@ -50,7 +50,7 @@ var cdf = require( '@stdlib/stats/base/dists/planck/cdf' );

#### cdf( x, lambda )

Evaluates the [cumulative distribution function][cdf] for a Planck distribution with shape parameter `λ`.
Evaluates the [cumulative distribution function][cdf] for a Planck (discrete exponential) distribution with shape parameter `lambda`.

```javascript
var y = cdf( 2.0, 0.5 );
Expand All @@ -70,7 +70,7 @@ y = cdf( 0.0, NaN );
// returns NaN
```

If provided a success probability `λ` which is nonpositive, the function returns `NaN`.
If provided a shape parameter `lambda` which is nonpositive, the function returns `NaN`.

```javascript
var y = cdf( 2.0, -1.0 );
Expand All @@ -79,7 +79,7 @@ var y = cdf( 2.0, -1.0 );

#### cdf.factory( lambda )

Returns a function for evaluating the [cumulative distribution function][cdf] of a Planck distribution with shape parameter `λ`.
Returns a function for evaluating the [cumulative distribution function][cdf] of a Planck (discrete exponential) distribution with shape parameter `lambda`.

```javascript
var mycdf = cdf.factory( 1.5 );
Expand All @@ -105,8 +105,8 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var cdf = require( '@stdlib/stats/base/dists/planck/cdf' );

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

var y;
var i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var cdf = require( './../lib' );

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

var y;
var i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function factory( lambda ) {
return cdf;

/**
* Evaluates the cumulative distribution function (CDF) for a geometric distribution.
* Evaluates the cumulative distribution function (CDF) for a Planck distribution.
*
* @private
* @param {number} x - input value
Expand All @@ -70,8 +70,7 @@ function factory( lambda ) {
if ( x === PINF ) {
return 1.0;
}
x = floor( x );
return -expm1( -lambda * (x + 1) );
return -expm1( -lambda * ( floor(x)+1.0 ) );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function cdf( x, lambda ) {
if ( x === PINF ) {
return 1.0;
}
x = floor( x );
return -expm1( -lambda * (x + 1) );
return -expm1( -lambda * ( floor(x)+1.0 ) );
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stdlib/stats/base/dists/planck/cdf",
"version": "0.0.0",
"description": "Planck distribution cumulative distribution function (CDF).",
"description": "Planck (discrete exponential) distribution cumulative distribution function (CDF).",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main():
"""Generate fixture data."""
# Large shape paramter:
x = np.round(np.random.rand(1000) * 10.0)
lam = (np.random.rand(1000) * 10) + 10
lam = (np.random.rand(1000) * 10.0) + 10.0
gen(x, lam, "large_lambda.json")

# Small shape parameter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ tape( 'if provided a negative number for `x` and a valid `lambda`, the function
tape( 'if provided a shape parameter `lambda` which is nonpositive, the function returns `NaN`', function test( t ) {
var y;

y = cdf( 2.0, 0.0 );
t.equal( isnan( y ), true, 'returns expected value' );

y = cdf( 2.0, -1.0 );
t.equal( isnan( y ), true, 'returns expected value' );

Expand All @@ -79,7 +82,7 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the function
t.end();
});

tape( 'the function evaluates the cdf for `x` given small parameter `lambda`', function test( t ) {
tape( 'the function evaluates the CDF for `x` given small parameter `lambda`', function test( t ) {
var expected;
var lambda;
var delta;
Expand All @@ -97,14 +100,14 @@ tape( 'the function evaluates the cdf for `x` given small parameter `lambda`', f
t.equal( y, expected[ i ], 'x: '+x[ i ]+', lambda: '+lambda[ i ]+', y: '+y+', expected: '+expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 20.0 * EPS * abs( expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. lambda: '+lambda[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
});

tape( 'the function evaluates the cdf for `x` given large parameter `lambda`', function test( t ) {
tape( 'the function evaluates the CDF for `x` given large parameter `lambda`', function test( t ) {
var expected;
var lambda;
var delta;
Expand All @@ -122,7 +125,7 @@ tape( 'the function evaluates the cdf for `x` given large parameter `lambda`', f
t.equal( y, expected[ i ], 'x: '+x[ i ]+', lambda: '+lambda[ i ]+', y: '+y+', expected: '+expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 20.0 * EPS * abs( expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. lambda: '+lambda[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the created
var cdf;
var y;

cdf = factory( 0.0 );
y = cdf( 2.0 );
t.equal( isnan( y ), true, 'returns NaN' );
y = cdf( 0.0 );
t.equal( isnan( y ), true, 'returns NaN' );

cdf = factory( -1.0 );
y = cdf( 2.0 );
t.equal( isnan( y ), true, 'returns NaN' );
Expand All @@ -108,7 +114,7 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the created
t.end();
});

tape( 'the created function evaluates the cdf for `x` given small parameter `lambda`', function test( t ) {
tape( 'the created function evaluates the CDF for `x` given small parameter `lambda`', function test( t ) {
var expected;
var lambda;
var delta;
Expand All @@ -128,14 +134,14 @@ tape( 'the created function evaluates the cdf for `x` given small parameter `lam
t.equal( y, expected[ i ], 'x: '+x[ i ]+', lambda: '+lambda[ i ]+', y: '+y+', expected: '+expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 20.0 * EPS * abs( expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. lambda: '+lambda[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
});

tape( 'the created function evaluates the cdf for `x` given large parameter `lambda`', function test( t ) {
tape( 'the created function evaluates the CDF for `x` given large parameter `lambda`', function test( t ) {
var expected;
var lambda;
var delta;
Expand All @@ -155,7 +161,7 @@ tape( 'the created function evaluates the cdf for `x` given large parameter `lam
t.equal( y, expected[ i ], 'x: '+x[ i ]+', lambda: '+lambda[ i ]+', y: '+y+', expected: '+expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 20.0 * EPS * abs( expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. lambda: '+lambda[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tape( 'main export is a function', function test( t ) {
t.end();
});

tape( 'attached to the main export is a factory method for generating `cdf` functions', function test( t ) {
tape( 'attached to the main export is a `factory` method for generating CDF functions', function test( t ) {
t.equal( typeof cdf.factory, 'function', 'exports a factory method' );
t.end();
});

0 comments on commit c197355

Please sign in to comment.