Skip to content

Commit 3c72680

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 b969863 commit 3c72680

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/node_modules/@stdlib/stats/strided/sztest/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2425
var quantile = require( '@stdlib/stats/base/dists/normal/quantile' ).factory;
2526
var cdf = require( '@stdlib/stats/base/dists/normal/cdf' ).factory;
@@ -47,7 +48,7 @@ var WORKSPACE = new Float32Array( 2 );
4748
* Computes a one-sample Z-test for a single-precision floating-point strided array using alternative indexing semantics.
4849
*
4950
* @param {PositiveInteger} N - number of indexed elements
50-
* @param {string} alternative - alternative hypothesis
51+
* @param {(integer|string)} alternative - alternative hypothesis
5152
* @param {number} alpha - significance level
5253
* @param {number} mu - mean under the null hypothesis
5354
* @param {PositiveNumber} sigma - known standard deviation
@@ -75,8 +76,10 @@ function sztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
7576
var stderr;
7677
var xmean;
7778
var stat;
79+
var alt;
7880
var q;
7981

82+
alt = resolveStr( alternative );
8083
if (
8184
N <= 0 ||
8285
isnanf( alpha ) ||
@@ -89,7 +92,7 @@ function sztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
8992
WORKSPACE[ 0 ] = NaN;
9093
WORKSPACE[ 1 ] = NaN;
9194
out.rejected = false;
92-
out.alternative = alternative;
95+
out.alternative = alt;
9396
out.alpha = NaN;
9497
out.pValue = NaN;
9598
out.statistic = NaN;
@@ -113,12 +116,12 @@ function sztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
113116
stat = ( xmean - mu ) / stderr;
114117

115118
// Compute the p-value and confidence interval...
116-
if ( alternative === 'less' ) {
119+
if ( alt === 'less' ) {
117120
pValue = normalCDF( stat );
118121
q = normalQuantile( 1.0-alpha );
119122
WORKSPACE[ 0 ] = NINF;
120123
WORKSPACE[ 1 ] = mu + ( (stat+q)*stderr );
121-
} else if ( alternative === 'greater' ) {
124+
} else if ( alt === 'greater' ) {
122125
pValue = 1.0 - normalCDF( stat );
123126
q = normalQuantile( 1.0-alpha );
124127
WORKSPACE[ 0 ] = mu + ( (stat-q)*stderr );
@@ -131,7 +134,7 @@ function sztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
131134
}
132135
// Return test results:
133136
out.rejected = ( pValue <= alpha );
134-
out.alternative = alternative;
137+
out.alternative = alt;
135138
out.alpha = alpha;
136139
out.pValue = f32( pValue );
137140
out.statistic = f32( stat );

lib/node_modules/@stdlib/stats/strided/sztest/lib/ndarray.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' );
3030
* Computes a one-sample Z-test for a single-precision floating-point strided array using alternative indexing semantics.
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/sztest/lib/sztest.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 single-precision floating-point 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/sztest/lib/sztest.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' );
3030
* Computes a one-sample Z-test for a single-precision floating-point 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

0 commit comments

Comments
 (0)