Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion lib/node_modules/@stdlib/stats/base/dnanvariancech/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ Note that indexing is relative to the first index. To introduce an offset, use [

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); // eslint-disable-line max-len

var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

var v = dnanvariancech( 5, 1, x1, 2 );
Expand Down
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/stats/base/meanpn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@license Apache-2.0

Copyright (c) 2020 The Stdlib Authors.
Copyright (c) 2025 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 @@ -51,7 +51,7 @@ The [arithmetic mean][arithmetic-mean] is defined as
var meanpn = require( '@stdlib/stats/base/meanpn' );
```

#### meanpn( N, x, stride )
#### meanpn( N, x, strideX )

Computes the [arithmetic mean][arithmetic-mean] of a strided array `x` using a two-pass error correction algorithm.

Expand All @@ -67,9 +67,9 @@ The function has the following parameters:

- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
- **stride**: index increment for `x`.
- **strideX**: stride length for `x`.

The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,

```javascript
var floor = require( '@stdlib/math/base/special/floor' );
Expand Down Expand Up @@ -98,7 +98,7 @@ var v = meanpn( N, x1, 2 );
// returns 1.25
```

#### meanpn.ndarray( N, x, stride, offset )
#### meanpn.ndarray( N, x, strideX, offsetX )

Computes the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm and alternative indexing semantics.

Expand All @@ -112,7 +112,7 @@ var v = meanpn.ndarray( N, x, 1, 0 );

The function has the following additional parameters:

- **offset**: starting index for `x`.
- **offsetX**: starting index for `x`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value

Expand Down
21 changes: 11 additions & 10 deletions lib/node_modules/@stdlib/stats/base/meanpn/benchmark/benchmark.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) 2025 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 All @@ -21,11 +21,18 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
var meanpn = require( './../lib/meanpn.js' );
var meanpn = require( './../lib/main.js' );


// VARIABLES //

var options = {
'dtype': 'generic'
};


// FUNCTIONS //
Expand All @@ -38,13 +45,7 @@ var meanpn = require( './../lib/meanpn.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = [];
for ( i = 0; i < len; i++ ) {
x.push( ( randu()*20.0 ) - 10.0 );
}
var x = uniform( len, -10, 10, options );
return benchmark;

function benchmark( b ) {
Expand Down
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) 2025 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
15 changes: 8 additions & 7 deletions lib/node_modules/@stdlib/stats/base/meanpn/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{{alias}}( N, x, stride )
{{alias}}( N, x, strideX )
Computes the arithmetic mean of a strided array using a two-pass error
correction algorithm.

Expand All @@ -19,8 +19,8 @@
x: Array<number>|TypedArray
Input array.

stride: integer
Index increment.
strideX: integer
Stride length.

Returns
-------
Expand Down Expand Up @@ -49,7 +49,8 @@
> {{alias}}( N, x1, stride )
~-0.3333

{{alias}}.ndarray( N, x, stride, offset )

{{alias}}.ndarray( N, x, strideX, offsetX )
Computes the arithmetic mean of a strided array using a two-pass error
correction algorithm and alternative indexing semantics.

Expand All @@ -65,10 +66,10 @@
x: Array<number>|TypedArray
Input array.

stride: integer
Index increment.
strideX: integer
Stride length.

offset: integer
offsetX: integer
Starting index.

Returns
Expand Down
21 changes: 13 additions & 8 deletions lib/node_modules/@stdlib/stats/base/meanpn/docs/types/index.d.ts
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) 2025 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 All @@ -20,7 +20,12 @@

/// <reference types="@stdlib/types"/>

import { NumericArray } from '@stdlib/types/array';
import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';

/**
* Input array.
*/
type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;

/**
* Interface describing `meanpn`.
Expand All @@ -31,7 +36,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns arithmetic mean
*
* @example
Expand All @@ -40,15 +45,15 @@ interface Routine {
* var v = meanpn( x.length, x, 1 );
* // returns ~0.3333
*/
( N: number, x: NumericArray, stride: number ): number;
( N: number, x: InputArray, stride: number ): number;

/**
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm and alternative indexing semantics.
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param offset - starting index
* @param strideX - stride length
* @param offsetX - starting index
* @returns arithmetic mean
*
* @example
Expand All @@ -57,15 +62,15 @@ interface Routine {
* var v = meanpn.ndarray( x.length, x, 1, 0 );
* // returns ~0.3333
*/
ndarray( N: number, x: NumericArray, stride: number, offset: number ): number;
ndarray( N: number, x: InputArray, stride: number, offsetX: number ): number;
}

/**
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm.
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns arithmetic mean
*
* @example
Expand Down
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) 2025 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 All @@ -16,6 +16,7 @@
* limitations under the License.
*/

import AccessorArray = require( '@stdlib/array/base/accessor' );
import meanpn = require( './index' );


Expand All @@ -26,6 +27,7 @@ import meanpn = require( './index' );
const x = new Float64Array( 10 );

meanpn( x.length, x, 1 ); // $ExpectType number
meanpn( x.length, new AccessorArray ( x ), 1 ); // $ExpectType number
}

// The compiler throws an error if the function is provided a first argument which is not a number...
Expand Down Expand Up @@ -85,6 +87,7 @@ import meanpn = require( './index' );
const x = new Float64Array( 10 );

meanpn.ndarray( x.length, x, 1, 0 ); // $ExpectType number
meanpn.ndarray( x.length, new AccessorArray ( x ), 1, 0 ); // $ExpectType number
}

// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
Expand Down
16 changes: 5 additions & 11 deletions lib/node_modules/@stdlib/stats/base/meanpn/examples/index.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) 2025 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 All @@ -18,18 +18,12 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var Float64Array = require( '@stdlib/array/float64' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var meanpn = require( './../lib' );

var x;
var i;

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( (randu()*100.0) - 50.0 );
}
var x = discreteUniform( 10, 0, 100, {
'dtype': 'float64'
});
console.log( x );

var v = meanpn( x.length, x, 1 );
Expand Down
77 changes: 77 additions & 0 deletions lib/node_modules/@stdlib/stats/base/meanpn/lib/accessors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var gsumpw = require( '@stdlib/blas/ext/base/gsumpw' ).ndarray;
var gapxsumpw = require( '@stdlib/blas/ext/base/gapxsumpw' ).ndarray;


// MAIN //

/**
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm.
*
* @param {PositiveInteger} N - number of indexed elements
* @param {NumericArray} x - input array
* @param {integer} strideX - stride length
* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} arithmetic mean
*
* @example
* var floor = require( '@stdlib/math/base/special/floor' );
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
*
* var x = toAccessorArray([ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]);
* var N = floor( x.length / 2 );
*
* var v = meanpn( N, arraylike2object(x), 2, 1 );
* // returns 1.25
*/
function meanpn( N, x, strideX, offsetX ) {
var xbuf;
var get;
var ix;
var mu;
var c;

xbuf = x.data;

get = x.accessors[ 0 ];

if ( N === 1 || strideX === 0 ) {
return get( xbuf, offsetX );
}

ix = offsetX;

// Compute an estimate for the meanpn:

Check warning on line 66 in lib/node_modules/@stdlib/stats/base/meanpn/lib/accessors.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "meanpn"
mu = gsumpw( N, xbuf, strideX, ix ) / N;

// Compute an error term:
c = gapxsumpw( N, -mu, xbuf, strideX, ix ) / N;
return mu + c;
}


// EXPORTS //

module.exports = meanpn;
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/stats/base/meanpn/lib/main.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) 2025 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
Loading