Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2d05be5
feat: add the C src files
anandkaranubc Jan 5, 2025
6e8eb2d
feat: add the C benchmark and example files
anandkaranubc Jan 5, 2025
8daa9ee
feat: add the JS native files
anandkaranubc Jan 5, 2025
f370792
build: added the json and gyp dependency files
anandkaranubc Jan 5, 2025
9937b76
docs: update README with C API documentation
anandkaranubc Jan 5, 2025
24e21c7
feat: add the C src files
anandkaranubc Jan 5, 2025
42d77e7
feat: add the C benchmark and example files
anandkaranubc Jan 5, 2025
9f37c82
feat: add the JS native files
anandkaranubc Jan 5, 2025
efe9448
build: added the json and gyp dependency files
anandkaranubc Jan 5, 2025
67f3f9e
docs: update README with C API documentation
anandkaranubc Jan 5, 2025
9e20d50
remove the pmf implementation
anandkaranubc Jan 5, 2025
24d15a0
refactor: fixed the formatting issues
anandkaranubc Jan 8, 2025
594e298
refactor: fixed extra spaces and tabs
anandkaranubc Jan 9, 2025
48b82bf
refactor: fixed header license
anandkaranubc Jan 9, 2025
3c6a7dd
refactor: fixed examples in native.js
anandkaranubc Jan 9, 2025
699f984
refactor: apply suggestions from previous PRs
anandkaranubc Jan 11, 2025
a6c3fa5
refactor: fix indentation of comments in header file
anandkaranubc Jan 11, 2025
f9c1aa8
Merge branch 'stdlib-js:develop' into rfc/hypergeom-logpmf
anandkaranubc Feb 17, 2025
fed37d8
Merge branch 'stdlib-js:develop' into rfc/hypergeom-logpmf
anandkaranubc Mar 1, 2025
42683e1
feat: temp commit
anandkaranubc Mar 1, 2025
3df0f9c
fix: update the C implementation with correct parameter types
anandkaranubc Mar 1, 2025
7de3df0
chore: apply suggestions from review
anandkaranubc Mar 2, 2025
fc88f46
chore: add missing opts
anandkaranubc Mar 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
#endif

/**
* Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K` and number of draws `n`.
* Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K`, and number of draws `n`.
*/
double stdlib_base_dists_hypergeometric_logpmf( const double x, const int32_t N, const int32_t K, const int32_t n );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' );
// MAIN //

/**
* Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K` and number of draws `n`.
* Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K`, and number of draws `n`.
*
* @param {number} x - input value
* @param {NonNegativeInteger} N - population size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K` and number of draws `n`.
* Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K`, and number of draws `n`.
*
* @private
* @param {number} x - input value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"dependencies": [
"@stdlib/math/base/napi/quaternary",
"@stdlib/math/base/assert/is-nonnegative-integer",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/ninf",
"@stdlib/math/base/special/factorialln",
"@stdlib/math/base/special/max",
Expand All @@ -59,6 +60,7 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nonnegative-integer",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/ninf",
"@stdlib/math/base/special/factorialln",
"@stdlib/math/base/special/max",
Expand All @@ -79,6 +81,7 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nonnegative-integer",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float64/ninf",
"@stdlib/math/base/special/factorialln",
"@stdlib/math/base/special/max",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ double stdlib_base_dists_hypergeometric_logpmf( const double x, const int32_t N,
double maxs;
double mins;

if ( N < 0 || K < 0 || n < 0 || K > N || n > N ) {
if ( stdlib_base_is_nan( x ) || N < 0 || K < 0 || n < 0 || K > N || n > N ) {
return 0.0/0.0; // NaN
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ tape( 'main export is a function', opts, function test( t ) {
t.end();
});

tape( 'if provided `NaN` for input value `x`, the function returns `NaN`', function test( t ) {
var y = logpmf( NaN, 10, 9, 5 );
t.equal( isnan( y ), true, 'returns expected value' );
t.end();
});

tape( 'if provided an integer `x` greater than `min( n, K )`, the function returns `-Infinity` (provided all parameters are valid)', opts, function test( t ) {
var y = logpmf( 11, 20, 20, 10 );
t.equal( y, NINF, 'returns expected value' );
Expand Down