Skip to content

Commit 3a44f75

Browse files
committed
fix: always resolve the alternative string
--- 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: 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 ---
1 parent dbbc745 commit 3a44f75

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/node_modules/@stdlib/stats/strided/ztest/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ndarray = require( './ndarray.js' );
3030
* Computes a one-sample Z-test for a strided array.
3131
*
3232
* @param {PositiveInteger} N - number of indexed elements
33-
* @param {string} alternative - alternative hypothesis
33+
* @param {(integer|string)} alternative - alternative hypothesis
3434
* @param {number} alpha - significance level
3535
* @param {number} mu - mean under the null hypothesis
3636
* @param {PositiveNumber} sigma - known standard deviation

lib/node_modules/@stdlib/stats/strided/ztest/lib/ndarray.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
// MODULES //
2222

23+
var resolveStr = require( '@stdlib/stats/base/ztest/alternative-resolve-str' );
2324
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2425
var quantile = require( '@stdlib/stats/base/dists/normal/quantile' ).factory;
2526
var cdf = require( '@stdlib/stats/base/dists/normal/cdf' ).factory;
@@ -46,7 +47,7 @@ var WORKSPACE = new Float64Array( 2 );
4647
* Computes a one-sample Z-test for a strided array using alternative indexing semantics.
4748
*
4849
* @param {PositiveInteger} N - number of indexed elements
49-
* @param {string} alternative - alternative hypothesis
50+
* @param {(integer|string)} alternative - alternative hypothesis
5051
* @param {number} alpha - significance level
5152
* @param {number} mu - mean under the null hypothesis
5253
* @param {PositiveNumber} sigma - known standard deviation
@@ -73,8 +74,10 @@ function ztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
7374
var stderr;
7475
var xmean;
7576
var stat;
77+
var alt;
7678
var q;
7779

80+
alt = resolveStr( alternative );
7881
if (
7982
N <= 0 ||
8083
isnan( alpha ) ||
@@ -87,7 +90,7 @@ function ztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
8790
WORKSPACE[ 0 ] = NaN;
8891
WORKSPACE[ 1 ] = NaN;
8992
out.rejected = false;
90-
out.alternative = alternative;
93+
out.alternative = alt;
9194
out.alpha = NaN;
9295
out.pValue = NaN;
9396
out.statistic = NaN;
@@ -106,12 +109,12 @@ function ztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
106109
stat = ( xmean - mu ) / stderr;
107110

108111
// Compute the p-value and confidence interval...
109-
if ( alternative === 'less' ) {
112+
if ( alt === 'less' ) {
110113
pValue = normalCDF( stat );
111114
q = normalQuantile( 1.0-alpha );
112115
WORKSPACE[ 0 ] = NINF;
113116
WORKSPACE[ 1 ] = mu + ( (stat+q)*stderr );
114-
} else if ( alternative === 'greater' ) {
117+
} else if ( alt === 'greater' ) {
115118
pValue = 1.0 - normalCDF( stat );
116119
q = normalQuantile( 1.0-alpha );
117120
WORKSPACE[ 0 ] = mu + ( (stat-q)*stderr );
@@ -124,7 +127,7 @@ function ztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
124127
}
125128
// Return test results:
126129
out.rejected = ( pValue <= alpha );
127-
out.alternative = alternative;
130+
out.alternative = alt;
128131
out.alpha = alpha;
129132
out.pValue = pValue;
130133
out.statistic = stat;

0 commit comments

Comments
 (0)