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