Skip to content

Commit 42683e1

Browse files
committed
feat: temp commit
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - 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 ---
1 parent fed37d8 commit 42683e1

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/include/stdlib/stats/base/dists/hypergeometric/logpmf.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef STDLIB_STATS_BASE_DISTS_HYPERGEOMETRIC_LOGPMF_H
2020
#define STDLIB_STATS_BASE_DISTS_HYPERGEOMETRIC_LOGPMF_H
2121

22+
#include <stdint.h>
23+
2224
/*
2325
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2426
*/
@@ -27,15 +29,9 @@ extern "C" {
2729
#endif
2830

2931
/**
30-
* 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`.
31-
*
32-
* @param x input value
33-
* @param N population size
34-
* @param K subpopulation size
35-
* @param n number of draws
36-
* @return evaluated logPMF
32+
* 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`.
3733
*/
38-
double stdlib_base_dists_hypergeometric_logpmf( const double x, const double N, const double K, const double n );
34+
double stdlib_base_dists_hypergeometric_logpmf( const double x, const int32_t N, const int32_t K, const int32_t n );
3935

4036
#ifdef __cplusplus
4137
}

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/lib/native.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ var addon = require( './../src/addon.node' );
2626
// MAIN //
2727

2828
/**
29-
* 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`.
29+
* 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`.
3030
*
31-
* @private
3231
* @param {number} x - input value
33-
* @param {number} N - population size
34-
* @param {number} K - subpopulation size
35-
* @param {number} n - number of draws
32+
* @param {NonNegativeInteger} N - population size
33+
* @param {NonNegativeInteger} K - subpopulation size
34+
* @param {NonNegativeInteger} n - number of draws
3635
* @returns {number} evaluated logPMF
3736
*
3837
* @example

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/src/addon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/napi/quaternary.h"
2019
#include "stdlib/stats/base/dists/hypergeometric/logpmf.h"
20+
#include "stdlib/math/base/napi/quaternary.h"
2121

2222
// cppcheck-suppress shadowFunction
23-
STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( stdlib_base_dists_hypergeometric_logpmf )
23+
STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( stdlib_base_dists_hypergeometric_logpmf )

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/src/main.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/constants/float64/ninf.h"
20-
#include "stdlib/constants/float64/pinf.h"
21-
#include "stdlib/math/base/assert/is_nan.h"
19+
#include "stdlib/stats/base/dists/hypergeometric/logpmf.h"
2220
#include "stdlib/math/base/assert/is_nonnegative_integer.h"
21+
#include "stdlib/math/base/assert/is_nan.h"
2322
#include "stdlib/math/base/special/factorialln.h"
2423
#include "stdlib/math/base/special/max.h"
2524
#include "stdlib/math/base/special/min.h"
25+
#include "stdlib/constants/float64/ninf.h"
26+
#include <stdint.h>
2627

2728
/**
2829
* 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`.
@@ -37,21 +38,24 @@
3738
* double y = stdlib_base_dists_hypergeometric_logpmf( 1.0, 8, 4, 2 );
3839
* // returns ~-0.56
3940
*/
40-
double stdlib_base_dists_hypergeometric_logpmf( const double x, const double N, const double K, const double n ) {
41-
if ( stdlib_base_is_nan( x ) || stdlib_base_is_nan( N ) || stdlib_base_is_nan( K ) || stdlib_base_is_nan( n ) || !stdlib_base_is_nonnegative_integer( N ) || !stdlib_base_is_nonnegative_integer( K ) || !stdlib_base_is_nonnegative_integer( n ) || N == STDLIB_CONSTANT_FLOAT64_PINF || K == STDLIB_CONSTANT_FLOAT64_PINF || K > N || n > N ) {
42-
return 0.0 / 0.0; // NaN
41+
double stdlib_base_dists_hypergeometric_logpmf( const double x, const int32_t N, const int32_t K, const int32_t n ) {
42+
double ldenom;
43+
double lnum;
44+
double maxs;
45+
double mins;
46+
47+
if ( N < 0 || K < 0 || n < 0 || K > N || n > N ) {
48+
return 0.0/0.0; // NaN
4349
}
4450

45-
double mins = stdlib_base_max( 0, n + K - N );
46-
double maxs = stdlib_base_min( K, n );
51+
mins = stdlib_base_max( 0, n+K-N );
52+
maxs = stdlib_base_min( K, n );
4753

4854
if ( stdlib_base_is_nonnegative_integer( x ) && mins <= x && x <= maxs ) {
49-
double lnum = stdlib_base_factorialln( n ) + stdlib_base_factorialln( K ) + stdlib_base_factorialln( N - n ) + stdlib_base_factorialln( N - K );
50-
51-
double ldenom = stdlib_base_factorialln( N ) + stdlib_base_factorialln( x ) + stdlib_base_factorialln( n - x ) + stdlib_base_factorialln( K - x ) + stdlib_base_factorialln( N - K + x - n );
52-
55+
lnum = stdlib_base_factorialln( n ) + stdlib_base_factorialln( K ) + stdlib_base_factorialln( N-n ) + stdlib_base_factorialln( N-K );
56+
ldenom = stdlib_base_factorialln( N ) + stdlib_base_factorialln( x ) + stdlib_base_factorialln( n-x );
57+
ldenom += stdlib_base_factorialln( K-x ) + stdlib_base_factorialln( N-K+x-n );
5358
return lnum - ldenom;
5459
}
55-
5660
return STDLIB_CONSTANT_FLOAT64_NINF;
5761
}

0 commit comments

Comments
 (0)