From 332c9189acfc08c9bc9a8f9e1b1069ab448ccad1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 9 Jul 2026 08:18:26 +0000 Subject: [PATCH] refactor: replace `isProbability` with inline range check in `stats/base/dists/geometric/mgf` Normalizes the probability-range validation in `@stdlib/stats/base/dists/geometric/mgf` (both `lib/main.js` and `lib/factory.js`) from `!isProbability( p )` to the inline form `isnan( p ) || p < 0.0 || p > 1.0` used by every other JS member of the `stats/base/dists/geometric` namespace, and removes the now-unused `@stdlib/math/base/assert/is-probability` require from both files. `isProbability( x )` is defined as `!isnan( x ) && x >= 0.0 && x <= 1.0`, so the two forms agree on NaN, +/-Infinity, and all finite inputs; observable behavior is preserved (boundary cases `p = 0`, `p = 1`, `p = NaN`, `p = +/-Infinity`, `p = -0.5`, `p = 2.0` all continue to return `NaN` or their prior finite value). Namespace conformance: 13 of 14 non-`ctor` sibling packages use the inline `isnan( p ) || p 0.0 || p 1.0` prologue (92.9%); `mgf` was the sole outlier using the predicate form. Mirrors the identical normalization applied to `stats/base/dists/bernoulli/mgf` in merged PR #12292, which flagged this package as the natural follow-up. --- .../@stdlib/stats/base/dists/geometric/mgf/lib/factory.js | 3 +-- .../@stdlib/stats/base/dists/geometric/mgf/lib/main.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/factory.js index d9d74dae0a1f..b2427c2bb1fa 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/factory.js @@ -21,7 +21,6 @@ // MODULES // var constantFunction = require( '@stdlib/utils/constant-function' ); -var isProbability = require( '@stdlib/math/base/assert/is-probability' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var exp = require( '@stdlib/math/base/special/exp' ); var ln = require( '@stdlib/math/base/special/ln' ); @@ -41,7 +40,7 @@ var ln = require( '@stdlib/math/base/special/ln' ); * // returns ~0.783 */ function factory( p ) { - if ( !isProbability( p ) ) { + if ( isnan( p ) || p < 0.0 || p > 1.0 ) { return constantFunction( NaN ); } return mgf; diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/main.js index 8126d1911512..956345a3cc36 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/mgf/lib/main.js @@ -20,7 +20,6 @@ // MODULES // -var isProbability = require( '@stdlib/math/base/assert/is-probability' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var exp = require( '@stdlib/math/base/special/exp' ); var ln = require( '@stdlib/math/base/special/ln' ); @@ -67,7 +66,7 @@ var ln = require( '@stdlib/math/base/special/ln' ); function mgf( t, p ) { var et; var q; - if ( isnan( t ) || !isProbability( p ) ) { + if ( isnan( t ) || isnan( p ) || p < 0.0 || p > 1.0 ) { return NaN; } q = 1.0 - p;