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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,37 @@
4
4
5
5
<sectionclass="release"id="unreleased">
6
6
7
-
## Unreleased (2025-06-23)
7
+
## Unreleased (2025-07-09)
8
+
9
+
<sectionclass="features">
10
+
11
+
### Features
12
+
13
+
-[`a0f761b`](https://github.com/stdlib-js/stdlib/commit/a0f761b72ab538e2a92f97a3ca6de7e53ed45004) - add support for accessor arrays and refactor `stats/base/nanstdevtk`[(#7589)](https://github.com/stdlib-js/stdlib/pull/7589)
-[`a0f761b`](https://github.com/stdlib-js/stdlib/commit/a0f761b72ab538e2a92f97a3ca6de7e53ed45004) - **feat:** add support for accessor arrays and refactor `stats/base/nanstdevtk`[(#7589)](https://github.com/stdlib-js/stdlib/pull/7589)_(by Gururaj Gurram)_
Copy file name to clipboardExpand all lines: README.md
+25-30Lines changed: 25 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,9 +131,9 @@ To view installation and usage instructions specific to each branch build, be su
131
131
var nanstdevtk =require( '@stdlib/stats-base-nanstdevtk' );
132
132
```
133
133
134
-
#### nanstdevtk( N, correction, x, stride )
134
+
#### nanstdevtk( N, correction, x, strideX )
135
135
136
-
Computes the [standard deviation][standard-deviation] of a strided array `x`ignoring `NaN` values and using a one-pass textbook algorithm.
136
+
Computes the [standard deviation][standard-deviation] of a strided array ignoring `NaN` values and using a one-pass textbook algorithm.
137
137
138
138
```javascript
139
139
var x = [ 1.0, -2.0, NaN, 2.0 ];
@@ -147,38 +147,32 @@ The function has the following parameters:
147
147
-**N**: number of indexed elements.
148
148
-**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).
149
149
-**x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
150
-
-**stride**: index increment for `x`.
150
+
-**strideX**: stride length for `x`.
151
151
152
152
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`,
153
153
154
154
```javascript
155
-
var floor =require( '@stdlib/math-base-special-floor' );
156
-
157
155
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ];
158
-
varN=floor( x.length/2 );
159
156
160
-
var v =nanstdevtk( N, 1, x, 2 );
157
+
var v =nanstdevtk( 5, 1, x, 2 );
161
158
// returns 2.5
162
159
```
163
160
164
161
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
var floor =require( '@stdlib/math-base-special-floor' );
171
167
172
-
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
168
+
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
173
169
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
174
170
175
-
varN=floor( x0.length/2 );
176
-
177
-
var v =nanstdevtk( N, 1, x1, 2 );
171
+
var v =nanstdevtk( 5, 1, x1, 2 );
178
172
// returns 2.5
179
173
```
180
174
181
-
#### nanstdevtk.ndarray( N, correction, x, stride, offset )
175
+
#### nanstdevtk.ndarray( N, correction, x, strideX, offsetX )
182
176
183
177
Computes the [standard deviation][standard-deviation] of a strided array ignoring `NaN` values and using a one-pass textbook algorithm and alternative indexing semantics.
184
178
@@ -191,17 +185,14 @@ var v = nanstdevtk.ndarray( x.length, 1, x, 1, 0 );
191
185
192
186
The function has the following additional parameters:
193
187
194
-
-**offset**: starting index for `x`.
188
+
-**offsetX**: starting index for `x`.
195
189
196
-
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
190
+
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 `x` starting from the second element
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
202
-
varN=floor( x.length/2 );
203
-
204
-
var v =nanstdevtk.ndarray( N, 1, x, 2, 1 );
195
+
var v =nanstdevtk.ndarray( 5, 1, x, 2, 1 );
205
196
// returns 2.5
206
197
```
207
198
@@ -216,6 +207,7 @@ var v = nanstdevtk.ndarray( N, 1, x, 2, 1 );
216
207
- If `N <= 0`, both functions return `NaN`.
217
208
- If `n - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements), both functions return `NaN`.
218
209
- Some caution should be exercised when using the one-pass textbook algorithm. Literature overwhelmingly discourages the algorithm's use for two reasons: 1) the lack of safeguards against underflow and overflow and 2) the risk of catastrophic cancellation when subtracting the two sums if the sums are large and the variance small. These concerns have merit; however, the one-pass textbook algorithm should not be dismissed outright. For data distributions with a moderately large standard deviation to mean ratio (i.e., **coefficient of variation**), the one-pass textbook algorithm may be acceptable, especially when performance is paramount and some precision loss is acceptable (including a risk of computing a negative variance due to floating-point rounding errors!). In short, no single "best" algorithm for computing the standard deviation exists. The "best" algorithm depends on the underlying data distribution, your performance requirements, and your minimum precision requirements. When evaluating which algorithm to use, consider the relative pros and cons, and choose the algorithm which best serves your needs.
210
+
- 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]).
219
211
- Depending on the environment, the typed versions ([`dnanstdevtk`][@stdlib/stats/strided/dnanstdevtk], [`snanstdevtk`][@stdlib/stats/base/snanstdevtk], etc.) are likely to be significantly more performant.
220
212
221
213
</section>
@@ -229,18 +221,19 @@ var v = nanstdevtk.ndarray( N, 1, x, 2, 1 );
0 commit comments