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
@@ -117,18 +116,16 @@ The function has the following parameters:
117
116
-**N**: number of indexed elements.
118
117
-**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).
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`,
121
+
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`,
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
145
141
146
-
varN=floor( x0.length/2 );
147
-
148
-
var v =dstdevwd( N, 1, x1, 2 );
142
+
var v =dstdevwd( 4, 1.0, x1, 2 );
149
143
// returns 2.5
150
144
```
151
145
152
-
#### dstdevwd.ndarray( N, correction, x, stride, offset )
146
+
#### dstdevwd.ndarray( N, correction, x, strideX, offsetX )
153
147
154
148
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using Welford's algorithm and alternative indexing semantics.
var v =dstdevwd.ndarray( x.length, 1.0, x, 1, 0 );
163
156
// returns ~2.0817
164
157
```
165
158
166
159
The function has the following additional parameters:
167
160
168
-
-**offset**: starting index for `x`.
161
+
-**offsetX**: starting index for `x`.
169
162
170
-
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
163
+
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 discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
208
197
var dstdevwd =require( '@stdlib/stats/base/dstdevwd' );
209
198
210
-
var x;
211
-
var i;
212
-
213
-
x =newFloat64Array( 10 );
214
-
for ( i =0; i <x.length; i++ ) {
215
-
x[ i ] =round( (randu()*100.0) -50.0 );
216
-
}
199
+
var x =discreteUniform( 10, -50, 50, {
200
+
'dtype':'float64'
201
+
});
217
202
console.log( x );
218
203
219
-
var v =dstdevwd( x.length, 1, x, 1 );
204
+
var v =dstdevwd( x.length, 1.0, x, 1 );
220
205
console.log( v );
221
206
```
222
207
223
208
</section>
224
209
225
210
<!-- /.examples -->
226
211
212
+
<!-- C interface documentation. -->
213
+
214
+
* * *
215
+
216
+
<sectionclass="c">
217
+
218
+
## C APIs
219
+
220
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
221
+
222
+
<sectionclass="intro">
223
+
224
+
</section>
225
+
226
+
<!-- /.intro -->
227
+
228
+
<!-- C usage documentation. -->
229
+
230
+
<sectionclass="usage">
231
+
232
+
### Usage
233
+
234
+
```c
235
+
#include"stdlib/stats/base/dstdevwd.h"
236
+
```
237
+
238
+
#### stdlib_strided_dstdevwd( N, correction, \*X, strideX )
239
+
240
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using Welford's algorithm.
241
+
242
+
```c
243
+
constdouble x[] = { 1.0, -2.0, 2.0 };
244
+
245
+
double v = stdlib_strided_dstdevwd( 3, 1.0, x, 1 );
246
+
// returns ~2.0817
247
+
```
248
+
249
+
The function accepts the following arguments:
250
+
251
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
252
+
- **correction**: `[in] double` 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).
253
+
- **X**: `[in] double*` input array.
254
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dstdevwd_ndarray( N, correction, \*X, strideX, offsetX )
261
+
262
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using Welford's algorithm and alternative indexing semantics.
263
+
264
+
```c
265
+
constdouble x[] = { 1.0, -2.0, 2.0 };
266
+
267
+
double v = stdlib_strided_dstdevwd_ndarray( 3, 1.0, x, 1, 0 );
268
+
// returns ~2.0817
269
+
```
270
+
271
+
The function accepts the following arguments:
272
+
273
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
274
+
- **correction**: `[in] double` 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).
275
+
- **X**: `[in] double*` input array.
276
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
277
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments