Repository: stdlib-js/stdlib (2025-04-03T03:07:59Z)

Issue:
[RFC]: refactor and add protocol support to `stats/base/stdevwd`
## Description

This RFC proposes refactoring and adding accessor protocol support to [`@stdlib/stats/base/stdevwd`](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/stdevwd).

For background on the accessor protocol, see https://blog.stdlib.io/introducing-the-accessor-protocol-for-array-like-objects/.

Examples of what we are looking for:

- `stats/base/min`: https://github.com/stdlib-js/stdlib/commit/fbb31fbaafbbbf233740a41a88a57f4db1cb427b ([package](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/min))
- `stats/base/cumax`: https://github.com/stdlib-js/stdlib/commit/11f1341134c5d6c7c0ecd82c99dff766e08e731a ([package](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/cumax))
- `stats/base/cumin`: https://github.com/stdlib-js/stdlib/commit/528efd8000eb7b910f64e63796a8a7c2fdfa03cd ([package](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/cumin))
- `stats/base/mediansorted`: https://github.com/stdlib-js/stdlib/commit/065f86535e3f1915160f91820f1fa0af79633b72 ([package](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/mediansorted))
- `stats/base/mskmax`: https://github.com/stdlib-js/stdlib/commit/417e65361234ec46382f58cc303a544f5bbcbf9e ([package](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/mskmax))

While the changes proposed in this RFC will **not** match the implementations found in the above packages, the packages should provide a conceptual idea of what is desired. Do **not** simply copy-paste the code found in those packages without reasoning about expected behavior and API design.

### Key Points

#### Refactoring

When refactoring and cleaning up existing implementations, pay special attention to the changes made in the commits referred to above. You'll need to go line-by-line in [`@stdlib/stats/base/stdevwd`](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/stdevwd) and compare with the changes made in the above commits.

In particular, we're interested in

1. standardizing language in descriptions so that all packages in `stats/base` use similar language for describing input parameters and behavior.
2. updating examples to align with current conventions in stdlib.
3. simplifying examples and benchmarks to use utilities for generating random arrays.
4. reducing code duplication by having the main package entry point delegate to the `ndarray` API.

#### Accessor protocol

Prior to adding accessor protocol support, check whether the implementation has any strided array dependencies. For example, for certain algorithms for computing the mean, implementations will depend on algorithms for computing the sum. Ensure that the upstream implementations have support for accessor arrays. If not, you'll need to open a separate PR adding support in the upstream dependencies before working on this package.

When adding support for the accessor protocol, you'll need to do the following:

##### Create an accessors file

Create a new `lib/accessors.js` file. This file will contain an implementation which can handle accessor arrays.

##### Modify the ndarray file

Modify the `lib/ndarray.js` file to delegate to the accessors implementation when one (or more) of the input arrays is an accessor array.

##### Update tests

Modify the tests to include explicit tests for accessor arrays.

#### Run tests and other commands

For each of the following commands, please run them from the root stdlib repository directory (not the package folder!).

To run unit tests,

```bash
make test TESTS_FILTER=".*/stats/base/stdevwd/.*"
```

To run examples,

```bash
make examples EXAMPLES_FILTER=".*/stats/base/stdevwd/.*"
```

To run benchmarks,

```bash
make benchmark BENCHMARKS_FILTER=".*/stats/base/stdevwd/.*"
```

### Create pull request

Provided all tests, examples, and benchmarks successfully execute and pass and that you've updated the package's documentation, you are now ready to open a pull request!

* * *

## Notes

- If you are interested in contributing a PR which addresses this RFC and still getting familiar with our project conventions, please do **not** submit LLM-generated code. Please consult our [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) and the associated [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md). Failure to respect project conventions will result in your PR being rejected without review. Thank you for understanding!

### Checklist

- [X] I have read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with `[RFC]:`.



Discussion:
# :wave: Important: PLEASE READ :wave:

This issue has been labeled as a **good first issue** and is available for anyone to work on.

If this is your first time contributing to an open source project, some aspects of the development process may seem unusual, arcane, or some combination of both.

1.  **You cannot "claim" issues.** People new to open source often want to "claim" or be assigned an issue before beginning work. The typical rationale is that people want to avoid wasted work in the event that someone else ends up working the issue. However, this practice is not effective in open source, as it often leads to "issue squatting", in which an individual asks to be assigned, is granted their request, and then never ends up working on the issue. Accordingly, you are encouraged to communicate your intent to address this issue, ideally by providing a rough outline as to how you plan to address the issue or asking clarifying questions, but, at the end of the day, we will take running code and rough consensus in order to move forward quickly.
2.  **We have a very high bar for contributions.** We have very high standards for contributions and expect all contributions—whether new features, tests, or documentation—to be rigorous, thorough, and complete. Once a pull request is merged into stdlib, that contribution immediately becomes the collective responsibility of all maintainers of stdlib. When we merge code into stdlib, we are saying that we, the maintainers, commit to reviewing subsequent changes and making bugfixes to the code. Hence, in order to ensure future maintainability, this naturally leads to a higher standard of contribution.

Before working on this issue and opening a pull request, please read the project's [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md). These guidelines and the associated [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) provide important information, including links to stdlib's [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md), license policy, and steps for setting up your local development environment.

To reiterate, we **strongly** encourage you to refer to our contributing guides **before** beginning work on this issue. Failure to follow our guidelines significantly decreases the likelihood that you'll successfully contribute to stdlib and may result in automatic closure of a pull request without review.

Setting up your local development environment is a critical first step, as doing so ensures that automated development processes for linting, license verification, and unit testing can run prior to authoring commits and pushing changes. If you would prefer to avoid manual setup, we provide pre-configured [development containers](https://github.com/stdlib-js/stdlib/tree/develop/.devcontainer) for use locally or in GitHub Codespaces.

We place a high value on consistency throughout the stdlib codebase. We encourage you to closely examine other packages in stdlib and attempt to emulate the practices and conventions found therein.

-   If you are attempting to contribute a new package, sometimes the best approach is to simply copy the contents of an existing package and then modify the minimum amount necessary to implement the feature (e.g., changing descriptions, parameter names, and implementation).
-   If you are contributing tests, find a package implementing a similar feature and emulate the tests of that package.
-   If you are updating documentation, examine several similar packages and emulate the content, style, and prose of those packages.

In short, the more effort you put in to ensure that your contribution looks and feels like stdlib—including variables names, bracket spacing, line breaks, etc—the more likely that your contribution will be reviewed and ultimately accepted. We encourage you to closely study the codebase **before** beginning work on this issue.

:sparkles: Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions. :sparkles:




Patch:
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/README.md b/lib/node_modules/@stdlib/stats/base/stdevwd/README.md
index dacfdb543972..a87eb8f7fdf7 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/README.md
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/README.md
@@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
 var stdevwd = require( '@stdlib/stats/base/stdevwd' );
 ```
 
-#### stdevwd( N, correction, x, stride )
+#### stdevwd( N, correction, x, strideX )
 
-Computes the [standard deviation][standard-deviation] of a strided array `x` using Welford's algorithm.
+Computes the [standard deviation][standard-deviation] of a strided array using Welford's algorithm.
 
 ```javascript
 var x = [ 1.0, -2.0, 2.0 ];
@@ -114,17 +114,14 @@ The function has the following parameters:
 -   **N**: number of indexed elements.
 -   **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
 -   **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 [standard deviation][standard-deviation] of every other element in `x`,
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
 
 ```javascript
-var floor = require( '@stdlib/math/base/special/floor' );
-
 var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
-var N = floor( x.length / 2 );
 
-var v = stdevwd( N, 1, x, 2 );
+var v = stdevwd( 4, 1, x, 2 );
 // returns 2.5
 ```
 
@@ -134,18 +131,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [
 
 ```javascript
 var Float64Array = require( '@stdlib/array/float64' );
-var floor = require( '@stdlib/math/base/special/floor' );
 
 var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
 var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
 
-var N = floor( x0.length / 2 );
-
-var v = stdevwd( N, 1, x1, 2 );
+var v = stdevwd( 4, 1, x1, 2 );
 // returns 2.5
 ```
 
-#### stdevwd.ndarray( N, correction, x, stride, offset )
+#### stdevwd.ndarray( N, correction, x, strideX, offsetX )
 
 Computes the [standard deviation][standard-deviation] of a strided array using Welford's algorithm and alternative indexing semantics.
 
@@ -158,17 +152,14 @@ var v = stdevwd.ndarray( x.length, 1, 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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
+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 [standard deviation][standard-deviation] for every other element in the strided array starting from the second element
 
 ```javascript
-var floor = require( '@stdlib/math/base/special/floor' );
-
 var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
-var N = floor( x.length / 2 );
 
-var v = stdevwd.ndarray( N, 1, x, 2, 1 );
+var v = stdevwd.ndarray( 4, 1, x, 2, 1 );
 // returns 2.5
 ```
 
@@ -182,6 +173,7 @@ var v = stdevwd.ndarray( N, 1, x, 2, 1 );
 
 -   If `N <= 0`, both functions return `NaN`.
 -   If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both functions return `NaN`.
+-   Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
 -   Depending on the environment, the typed versions ([`dstdevwd`][@stdlib/stats/strided/dstdevwd], [`sstdevwd`][@stdlib/stats/base/sstdevwd], etc.) are likely to be significantly more performant.
 
 </section>
@@ -195,18 +187,12 @@ var v = stdevwd.ndarray( N, 1, x, 2, 1 );
 <!-- eslint no-undef: "error" -->
 
 ```javascript
-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 stdevwd = require( '@stdlib/stats/base/stdevwd' );
 
-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, -50, 50, {
+    'dtype': 'float64'
+});
 console.log( x );
 
 var v = stdevwd( x.length, 1, x, 1 );
@@ -258,6 +244,8 @@ console.log( v );
 
 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
 
+[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
+
 [@welford:1962a]: https://doi.org/10.1080/00401706.1962.10490022
 
 [@vanreeken:1968a]: https://doi.org/10.1145/362929.362961
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js
index 73ebd0677e56..1dce7798ef99 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.js
@@ -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 stdevwd = require( './../lib/stdevwd.js' );
+var stdevwd = require( './../lib/main.js' );
+
+
+// VARIABLES //
+
+var options = {
+	'dtype': 'generic'
+};
 
 
 // FUNCTIONS //
@@ -38,13 +45,7 @@ var stdevwd = require( './../lib/stdevwd.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 ) {
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js
index 040cda910a37..a35722b0a1a0 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/benchmark/benchmark.ndarray.js
@@ -21,13 +21,20 @@
 // 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 stdevwd = require( './../lib/ndarray.js' );
 
 
+// VARIABLES //
+
+var options = {
+	'dtype': 'generic'
+};
+
+
 // FUNCTIONS //
 
 /**
@@ -38,13 +45,7 @@ var stdevwd = require( './../lib/ndarray.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 ) {
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt
index 97e16cd66337..8bc6ec26f103 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/repl.txt
@@ -1,10 +1,10 @@
 
-{{alias}}( N, correction, x, stride )
+{{alias}}( N, correction, x, strideX )
     Computes the standard deviation of a strided array using Welford's
     algorithm.
 
-    The `N` and `stride` parameters determine which elements in `x` are accessed
-    at runtime.
+    The `N` and stride parameters determine which elements in the strided array
+    are accessed at runtime.
 
     Indexing is relative to the first index. To introduce an offset, use a typed
     array view.
@@ -31,8 +31,8 @@
     x: Array<number>|TypedArray
         Input array.
 
-    stride: integer
-        Index increment.
+    strideX: integer
+        Stride length.
 
     Returns
     -------
@@ -46,27 +46,24 @@
     > {{alias}}( x.length, 1, x, 1 )
     ~2.0817
 
-    // Using `N` and `stride` parameters:
+    // Using `N` and stride parameters:
     > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ];
-    > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
-    > var stride = 2;
-    > {{alias}}( N, 1, x, stride )
+    > {{alias}}( 3, 1, x, 2 )
     ~2.0817
 
     // Using view offsets:
     > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
     > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
-    > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
-    > stride = 2;
-    > {{alias}}( N, 1, x1, stride )
+    > {{alias}}( 3, 1, x1, 2 )
     ~2.0817
 
-{{alias}}.ndarray( N, correction, x, stride, offset )
+
+{{alias}}.ndarray( N, correction, x, strideX, offsetX )
     Computes the standard deviation of a strided array using Welford's algorithm
     and alternative indexing semantics.
 
     While typed array views mandate a view offset based on the underlying
-    buffer, the `offset` parameter supports indexing semantics based on a
+    buffer, the offset parameter supports indexing semantics based on a
     starting index.
 
     Parameters
@@ -89,10 +86,10 @@
     x: Array<number>|TypedArray
         Input array.
 
-    stride: integer
-        Index increment.
+    strideX: integer
+        Stride length.
 
-    offset: integer
+    offsetX: integer
         Starting index.
 
     Returns
@@ -108,9 +105,8 @@
     ~2.0817
 
     // Using offset parameter:
-    > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
-    > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
-    > {{alias}}.ndarray( N, 1, x, 2, 1 )
+    > x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
+    > {{alias}}.ndarray( 3, 1, x, 2, 1 )
     ~2.0817
 
     See Also
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts
index 5d2ae57995a1..74822c77fe45 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/index.d.ts
@@ -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 `stdevwd`.
@@ -32,7 +37,7 @@ interface Routine {
 	* @param N - number of indexed elements
 	* @param correction - degrees of freedom adjustment
 	* @param x - input array
-	* @param stride - stride length
+	* @param strideX - stride length
 	* @returns standard deviation
 	*
 	* @example
@@ -41,7 +46,7 @@ interface Routine {
 	* var v = stdevwd( x.length, 1, x, 1 );
 	* // returns ~2.0817
 	*/
-	( N: number, correction: number, x: NumericArray, stride: number ): number;
+	( N: number, correction: number, x: InputArray, strideX: number ): number;
 
 	/**
 	* Computes the standard deviation of a strided array using Welford's algorithm and alternative indexing semantics.
@@ -49,8 +54,8 @@ interface Routine {
 	* @param N - number of indexed elements
 	* @param correction - degrees of freedom adjustment
 	* @param x - input array
-	* @param stride - stride length
-	* @param offset - starting index
+	* @param strideX - stride length
+	* @param offsetX - starting index
 	* @returns standard deviation
 	*
 	* @example
@@ -59,7 +64,7 @@ interface Routine {
 	* var v = stdevwd.ndarray( x.length, 1, x, 1, 0 );
 	* // returns ~2.0817
 	*/
-	ndarray( N: number, correction: number, x: NumericArray, stride: number, offset: number ): number;
+	ndarray( N: number, correction: number, x: InputArray, strideX: number, offsetX: number ): number;
 }
 
 /**
@@ -68,7 +73,7 @@ interface Routine {
 * @param N - number of indexed elements
 * @param correction - degrees of freedom adjustment
 * @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
 * @returns standard deviation
 *
 * @example
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js b/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js
index 02ea6cb7e1a2..1e15a9bef0e2 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/examples/index.js
@@ -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 stdevwd = 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, -50, 50, {
+	'dtype': 'float64'
+});
 console.log( x );
 
 var v = stdevwd( x.length, 1, x, 1 );
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js
index 3d31b99ba6a7..0c8641bb089a 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/index.js
@@ -32,13 +32,11 @@
 * // returns ~2.0817
 *
 * @example
-* var floor = require( '@stdlib/math/base/special/floor' );
 * var stdevwd = require( '@stdlib/stats/base/stdevwd' );
 *
 * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
-* var N = floor( x.length / 2 );
 *
-* var v = stdevwd.ndarray( N, 1, x, 2, 1 );
+* var v = stdevwd.ndarray( 4, 1, x, 2, 1 );
 * // returns 2.5
 */
 
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js
index f31809bdc91f..c279156b14b0 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/ndarray.js
@@ -37,21 +37,18 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
 * @param {PositiveInteger} N - number of indexed elements
 * @param {number} correction - degrees of freedom adjustment
 * @param {NumericArray} x - input array
-* @param {integer} stride - stride length
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
 * @returns {number} standard deviation
 *
 * @example
-* var floor = require( '@stdlib/math/base/special/floor' );
-*
 * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
-* var N = floor( x.length / 2 );
 *
-* var v = stdevwd( N, 1, x, 2, 1 );
+* var v = stdevwd( 4, 1, x, 2, 1 );
 * // returns 2.5
 */
-function stdevwd( N, correction, x, stride, offset ) {
-	return sqrt( variancewd( N, correction, x, stride, offset ) );
+function stdevwd( N, correction, x, strideX, offsetX ) {
+	return sqrt( variancewd( N, correction, x, strideX, offsetX ) );
 }
 
 
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js
index 326eaf7f016d..91c2e166ae6f 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/lib/stdevwd.js
@@ -20,8 +20,8 @@
 
 // MODULES //
 
-var variancewd = require( '@stdlib/stats/strided/variancewd' );
-var sqrt = require( '@stdlib/math/base/special/sqrt' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
 
 
 // MAIN //
@@ -37,7 +37,7 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
 * @param {PositiveInteger} N - number of indexed elements
 * @param {number} correction - degrees of freedom adjustment
 * @param {NumericArray} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
 * @returns {number} standard deviation
 *
 * @example
@@ -46,8 +46,8 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
 * var v = stdevwd( x.length, 1, x, 1 );
 * // returns ~2.0817
 */
-function stdevwd( N, correction, x, stride ) {
-	return sqrt( variancewd( N, correction, x, stride ) );
+function stdevwd( N, correction, x, strideX ) {
+	return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) );
 }
 
 


Test patch:
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts
index 2af2b66461f1..f4d526b751ab 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/docs/types/test.ts
@@ -16,6 +16,7 @@
 * limitations under the License.
 */
 
+import AccessorArray = require( '@stdlib/array/base/accessor' );
 import stdevwd = require( './index' );
 
 
@@ -26,6 +27,7 @@ import stdevwd = require( './index' );
 	const x = new Float64Array( 10 );
 
 	stdevwd( x.length, 1, x, 1 ); // $ExpectType number
+	stdevwd( x.length, 1, new AccessorArray( x ), 1 ); // $ExpectType number
 }
 
 // The compiler throws an error if the function is provided a first argument which is not a number...
@@ -101,6 +103,7 @@ import stdevwd = require( './index' );
 	const x = new Float64Array( 10 );
 
 	stdevwd.ndarray( x.length, 1, x, 1, 0 ); // $ExpectType number
+	stdevwd.ndarray( x.length, 1, 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...
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js
similarity index 52%
rename from lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js
rename to lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js
index dcf840ce4032..f54420c59298 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.stdevwd.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.main.js
@@ -21,11 +21,11 @@
 // MODULES //
 
 var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
 var sqrt = require( '@stdlib/math/base/special/sqrt' );
 var isnan = require( '@stdlib/math/base/assert/is-nan' );
 var Float64Array = require( '@stdlib/array/float64' );
-var stdevwd = require( './../lib/stdevwd.js' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+var stdevwd = require( './../lib' );
 
 
 // TESTS //
@@ -60,6 +60,25 @@ tape( 'the function calculates the population standard deviation of a strided ar
 	t.end();
 });
 
+tape( 'the function calculates the population standard deviation of a strided array (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ];
+	v = stdevwd( x.length, 0, toAccessorArray( x ), 1 );
+	t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' );
+
+	x = [ -4.0, -4.0 ];
+	v = stdevwd( x.length, 0, toAccessorArray( x ), 1 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	x = [ NaN, 4.0 ];
+	v = stdevwd( x.length, 0, toAccessorArray( x ), 1 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'the function calculates the sample standard deviation of a strided array', function test( t ) {
 	var x;
 	var v;
@@ -79,6 +98,25 @@ tape( 'the function calculates the sample standard deviation of a strided array'
 	t.end();
 });
 
+tape( 'the function calculates the sample standard deviation of a strided array (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ];
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 1 );
+	t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' );
+
+	x = [ -4.0, -4.0 ];
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 1 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	x = [ NaN, 4.0 ];
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 1 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
 	var x;
 	var v;
@@ -94,6 +132,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
 	t.end();
 });
 
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( 0, 1, toAccessorArray( x ), 1 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	v = stdevwd( -1, 1, toAccessorArray( x ), 1 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0`', function test( t ) {
 	var x;
 	var v;
@@ -106,6 +159,18 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
 	t.end();
 });
 
+tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( 1, 0, toAccessorArray( x ), 1 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN`', function test( t ) {
 	var x;
 	var v;
@@ -121,8 +186,22 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
 	t.end();
 });
 
+tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( x.length, x.length, toAccessorArray( x ), 1 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	v = stdevwd( x.length, x.length+1, toAccessorArray( x ), 1 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'the function supports a `stride` parameter', function test( t ) {
-	var N;
 	var x;
 	var v;
 
@@ -137,15 +216,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
 		2.0
 	];
 
-	N = floor( x.length / 2 );
-	v = stdevwd( N, 1, x, 2 );
+	v = stdevwd( 4, 1, x, 2 );
+
+	t.strictEqual( v, 2.5, 'returns expected value' );
+	t.end();
+});
+
+tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [
+		1.0,  // 0
+		2.0,
+		2.0,  // 1
+		-7.0,
+		-2.0, // 2
+		3.0,
+		4.0,  // 3
+		2.0
+	];
+
+	v = stdevwd( 4, 1, toAccessorArray( x ), 2 );
 
 	t.strictEqual( v, 2.5, 'returns expected value' );
 	t.end();
 });
 
 tape( 'the function supports a negative `stride` parameter', function test( t ) {
-	var N;
 	var x;
 	var v;
 
@@ -160,8 +258,28 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
 		2.0
 	];
 
-	N = floor( x.length / 2 );
-	v = stdevwd( N, 1, x, -2 );
+	v = stdevwd( 4, 1, x, -2 );
+
+	t.strictEqual( v, 2.5, 'returns expected value' );
+	t.end();
+});
+
+tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [
+		1.0,  // 3
+		2.0,
+		2.0,  // 2
+		-7.0,
+		-2.0, // 1
+		3.0,
+		4.0,  // 0
+		2.0
+	];
+
+	v = stdevwd( 4, 1, toAccessorArray( x ), -2 );
 
 	t.strictEqual( v, 2.5, 'returns expected value' );
 	t.end();
@@ -179,10 +297,21 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
 	t.end();
 });
 
+tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 0 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'the function supports view offsets', function test( t ) {
 	var x0;
 	var x1;
-	var N;
 	var v;
 
 	x0 = new Float64Array([
@@ -198,9 +327,33 @@ tape( 'the function supports view offsets', function test( t ) {
 	]);
 
 	x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
-	N = floor(x1.length / 2);
 
-	v = stdevwd( N, 1, x1, 2 );
+	v = stdevwd( 4, 1, x1, 2 );
+	t.strictEqual( v, 2.5, 'returns expected value' );
+
+	t.end();
+});
+
+tape( 'the function supports view offsets (accessors)', function test( t ) {
+	var x0;
+	var x1;
+	var v;
+
+	x0 = new Float64Array([
+		2.0,
+		1.0,  // 0
+		2.0,
+		-2.0, // 1
+		-2.0,
+		2.0,  // 2
+		3.0,
+		4.0,  // 3
+		6.0
+	]);
+
+	x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
+
+	v = stdevwd( 4, 1, toAccessorArray( x1 ), 2 );
 	t.strictEqual( v, 2.5, 'returns expected value' );
 
 	t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js
index 0b5022acab72..18ee231bed15 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevwd/test/test.ndarray.js
@@ -21,9 +21,9 @@
 // MODULES //
 
 var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
 var sqrt = require( '@stdlib/math/base/special/sqrt' );
 var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
 var stdevwd = require( './../lib/ndarray.js' );
 
 
@@ -59,6 +59,25 @@ tape( 'the function calculates the population standard deviation of a strided ar
 	t.end();
 });
 
+tape( 'the function calculates the population standard deviation of a strided array (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ];
+	v = stdevwd( x.length, 0, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' );
+
+	x = [ -4.0, -4.0 ];
+	v = stdevwd( x.length, 0, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	x = [ NaN, 4.0 ];
+	v = stdevwd( x.length, 0, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'the function calculates the sample standard deviation of a strided array', function test( t ) {
 	var x;
 	var v;
@@ -78,6 +97,25 @@ tape( 'the function calculates the sample standard deviation of a strided array'
 	t.end();
 });
 
+tape( 'the function calculates the sample standard deviation of a strided array (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ];
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' );
+
+	x = [ -4.0, -4.0 ];
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	x = [ NaN, 4.0 ];
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
 	var x;
 	var v;
@@ -93,6 +131,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
 	t.end();
 });
 
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( 0, 1, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	v = stdevwd( -1, 1, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0`', function test( t ) {
 	var x;
 	var v;
@@ -105,6 +158,18 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
 	t.end();
 });
 
+tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( 1, 0, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN`', function test( t ) {
 	var x;
 	var v;
@@ -120,8 +185,22 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
 	t.end();
 });
 
+tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( x.length, x.length, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	v = stdevwd( x.length, x.length+1, toAccessorArray( x ), 1, 0 );
+	t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'the function supports a `stride` parameter', function test( t ) {
-	var N;
 	var x;
 	var v;
 
@@ -136,15 +215,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
 		2.0
 	];
 
-	N = floor( x.length / 2 );
-	v = stdevwd( N, 1, x, 2, 0 );
+	v = stdevwd( 4, 1, x, 2, 0 );
+
+	t.strictEqual( v, 2.5, 'returns expected value' );
+	t.end();
+});
+
+tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [
+		1.0,  // 0
+		2.0,
+		2.0,  // 1
+		-7.0,
+		-2.0, // 2
+		3.0,
+		4.0,  // 3
+		2.0
+	];
+
+	v = stdevwd( 4, 1, toAccessorArray( x ), 2, 0 );
 
 	t.strictEqual( v, 2.5, 'returns expected value' );
 	t.end();
 });
 
 tape( 'the function supports a negative `stride` parameter', function test( t ) {
-	var N;
 	var x;
 	var v;
 
@@ -159,8 +257,28 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
 		2.0
 	];
 
-	N = floor( x.length / 2 );
-	v = stdevwd( N, 1, x, -2, 6 );
+	v = stdevwd( 4, 1, x, -2, 6 );
+
+	t.strictEqual( v, 2.5, 'returns expected value' );
+	t.end();
+});
+
+tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [
+		1.0,  // 3
+		2.0,
+		2.0,  // 2
+		-7.0,
+		-2.0, // 1
+		3.0,
+		4.0,  // 0
+		2.0
+	];
+
+	v = stdevwd( 4, 1, toAccessorArray( x ), -2, 6 );
 
 	t.strictEqual( v, 2.5, 'returns expected value' );
 	t.end();
@@ -178,8 +296,19 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
 	t.end();
 });
 
+tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+	v = stdevwd( x.length, 1, toAccessorArray( x ), 0, 0 );
+	t.strictEqual( v, 0.0, 'returns expected value' );
+
+	t.end();
+});
+
 tape( 'the function supports an `offset` parameter', function test( t ) {
-	var N;
 	var x;
 	var v;
 
@@ -193,9 +322,29 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
 		3.0,
 		4.0   // 3
 	];
-	N = floor( x.length / 2 );
 
-	v = stdevwd( N, 1, x, 2, 1 );
+	v = stdevwd( 4, 1, x, 2, 1 );
+	t.strictEqual( v, 2.5, 'returns expected value' );
+
+	t.end();
+});
+
+tape( 'the function supports an `offset` parameter (accessors)', function test( t ) {
+	var x;
+	var v;
+
+	x = [
+		2.0,
+		1.0,  // 0
+		2.0,
+		-2.0, // 1
+		-2.0,
+		2.0,  // 2
+		3.0,
+		4.0   // 3
+	];
+
+	v = stdevwd( 4, 1, toAccessorArray( x ), 2, 1 );
 	t.strictEqual( v, 2.5, 'returns expected value' );
 
 	t.end();