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
* Licensed under the Apache License, Version 2.0 (the "License");
196
+
* you may not use this file except in compliance with the License.
197
+
* You may obtain a copy of the License at
198
+
*
199
+
* http://www.apache.org/licenses/LICENSE-2.0
200
+
*
201
+
* Unless required by applicable law or agreed to in writing, software
202
+
* distributed under the License is distributed on an "AS IS" BASIS,
203
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
204
+
* See the License for the specific language governing permissions and
205
+
* limitations under the License.
206
+
*/
207
+
208
+
'use strict';
209
+
210
+
// MODULES //
211
+
212
+
var stride2offset = require( '@stdlib/strided/base/stride2offset' );
213
+
var ndarray = require( './ndarray.js' );
214
+
215
+
216
+
// MAIN //
217
+
218
+
/**
219
+
* Computes the variance of a single-precision floating-point strided array using a two-pass algorithm with extended accumulation and returning an extended precision result.
220
+
*
221
+
* ## Method
222
+
*
223
+
* - This implementation uses a two-pass approach, as suggested by Neely (1966).
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
+
* - 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).
229
+
*
230
+
* @param {PositiveInteger} N - number of indexed elements
231
+
* @param {number} correction - degrees of freedom adjustment
232
+
* @param {Float32Array} x - input array
233
+
* @param {integer} strideX - stride length
234
+
* @returns {number} variance
235
+
*
236
+
* @example
237
+
* var Float32Array = require( '@stdlib/array/float32' );
238
+
*
239
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
240
+
*
241
+
* var v = dsvariancepn( x.length, 1, x, 1 );
242
+
* // returns ~4.3333
243
+
*/
244
+
function dsvariancepn( N, correction, x, strideX ) {
245
+
return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) );
246
+
}
247
+
248
+
249
+
// EXPORTS //
250
+
251
+
module.exports = dsvariancepn;
252
+
</pre></td></tr></table></pre>
253
+
254
+
<divclass='push'></div><!-- for sticky footer -->
255
+
</div><!-- /wrapper -->
256
+
<divclass='footer quiet pad2 space-top1 center small'>
0 commit comments