Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/node_modules/@stdlib/stats/base/meanpn/lib/ndarray.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,6 +53,19 @@ var gapxsumpw = require( '@stdlib/blas/ext/base/gapxsumpw' ).ndarray;
* var v = meanpn( N, x, 2, 1 );
* // returns 1.25
*/

// cspell:ignore meanpn

/**
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm.
*
* @private
* @param {PositiveInteger} N - number of indexed elements
* @param {NumericArray} x - input array
* @param {integer} stride - stride length
* @param {NonNegativeInteger} offset - starting index
* @returns {number} arithmetic mean
*/
function meanpn( N, x, stride, offset ) {
var mu;
var c;
Expand All @@ -63,7 +76,7 @@ function meanpn( N, x, stride, offset ) {
if ( N === 1 || stride === 0 ) {
return x[ offset ];
}
// Compute an estimate for the meanpn:
// Compute an estimate for the mean:
mu = gsumpw( N, x, stride, offset ) / N;

// Compute an error term:
Expand Down