Skip to content

Commit b969863

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

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/node_modules/@stdlib/stats/strided/dztest/lib/dztest.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 double-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/dztest/lib/dztest.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 double-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/dztest/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 double-precision floating-point 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
@@ -74,8 +75,10 @@ function dztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
7475
var stderr;
7576
var xmean;
7677
var stat;
78+
var alt;
7779
var q;
7880

81+
alt = resolveStr( alternative );
7982
if (
8083
N <= 0 ||
8184
isnan( alpha ) ||
@@ -88,7 +91,7 @@ function dztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
8891
WORKSPACE[ 0 ] = NaN;
8992
WORKSPACE[ 1 ] = NaN;
9093
out.rejected = false;
91-
out.alternative = alternative;
94+
out.alternative = alt;
9295
out.alpha = NaN;
9396
out.pValue = NaN;
9497
out.statistic = NaN;
@@ -107,12 +110,12 @@ function dztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
107110
stat = ( xmean - mu ) / stderr;
108111

109112
// Compute the p-value and confidence interval...
110-
if ( alternative === 'less' ) {
113+
if ( alt === 'less' ) {
111114
pValue = normalCDF( stat );
112115
q = normalQuantile( 1.0-alpha );
113116
WORKSPACE[ 0 ] = NINF;
114117
WORKSPACE[ 1 ] = mu + ( (stat+q)*stderr );
115-
} else if ( alternative === 'greater' ) {
118+
} else if ( alt === 'greater' ) {
116119
pValue = 1.0 - normalCDF( stat );
117120
q = normalQuantile( 1.0-alpha );
118121
WORKSPACE[ 0 ] = mu + ( (stat-q)*stderr );
@@ -125,7 +128,7 @@ function dztest( N, alternative, alpha, mu, sigma, x, strideX, offsetX, out ) {
125128
}
126129
// Return test results:
127130
out.rejected = ( pValue <= alpha );
128-
out.alternative = alternative;
131+
out.alternative = alt;
129132
out.alpha = alpha;
130133
out.pValue = pValue;
131134
out.statistic = stat;

lib/node_modules/@stdlib/stats/strided/dztest/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 double-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

0 commit comments

Comments
 (0)