You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
159
-
var nanvariancech = require( './nanvariancech.js' );
212
+
var stride2offset = require( '@stdlib/strided/base/stride2offset' );
160
213
var ndarray = require( './ndarray.js' );
161
214
162
215
163
216
// MAIN //
164
217
165
-
setReadOnly( nanvariancech, 'ndarray', ndarray );
218
+
/**
219
+
* Computes the variance of a strided array ignoring `NaN` values and using a one-pass trial mean algorithm.
220
+
*
221
+
* ## Method
222
+
*
223
+
* - This implementation uses a one-pass trial mean approach, as suggested by Chan et al (1983).
224
+
*
225
+
* ## References
226
+
*
227
+
* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
228
+
* - Ling, Robert F. 1974. "Comparison of Several Algorithms for Computing Sample Means and Variances." _Journal of the American Statistical Association_ 69 (348). American Statistical Association, Taylor & Francis, Ltd.: 859–66. doi:[10.2307/2286154](https://doi.org/10.2307/2286154).
229
+
* - Chan, Tony F., Gene H. Golub, and Randall J. LeVeque. 1983. "Algorithms for Computing the Sample Variance: Analysis and Recommendations." _The American Statistician_ 37 (3). American Statistical Association, Taylor & Francis, Ltd.: 242–47. doi:[10.1080/00031305.1983.10483115](https://doi.org/10.1080/00031305.1983.10483115).
230
+
* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
231
+
*
232
+
* @param {PositiveInteger} N - number of indexed elements
233
+
* @param {number} correction - degrees of freedom adjustment
234
+
* @param {NumericArray} x - input array
235
+
* @param {integer} strideX - stride length
236
+
* @returns {number} variance
237
+
*
238
+
* @example
239
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
240
+
*
241
+
* var v = nanvariancech( 4, 1, x, 1 );
242
+
* // returns ~4.3333
243
+
*/
244
+
function nanvariancech( N, correction, x, strideX ) {
245
+
return ndarray( N, correction, x, strideX, stride2offset( N, strideX) );
0 commit comments