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 =dstdevtk( N, 1, x1, 2 );
142
+
var v =dstdevtk( 4, 1.0, x1, 2 );
149
143
// returns 2.5
150
144
```
151
145
152
-
#### dstdevtk.ndarray( N, correction, x, stride, offset )
146
+
#### dstdevtk.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 a one-pass textbook algorithm and alternative indexing semantics.
var v =dstdevtk.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' );
209
198
var dstdevtk =require( '@stdlib/stats/base/dstdevtk' );
210
199
211
-
var x;
212
-
var i;
213
-
214
-
x =newFloat64Array( 10 );
215
-
for ( i =0; i <x.length; i++ ) {
216
-
x[ i ] =round( (randu()*100.0) -50.0 );
217
-
}
200
+
var x =discreteUniform( 10, -50, 50, {
201
+
'dtype':'float64'
202
+
});
218
203
console.log( x );
219
204
220
-
var v =dstdevtk( x.length, 1, x, 1 );
205
+
var v =dstdevtk( x.length, 1.0, x, 1 );
221
206
console.log( v );
222
207
```
223
208
224
209
</section>
225
210
226
211
<!-- /.examples -->
227
212
213
+
<!-- C interface documentation. -->
214
+
215
+
* * *
216
+
217
+
<sectionclass="c">
218
+
219
+
## C APIs
220
+
221
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
222
+
223
+
<sectionclass="intro">
224
+
225
+
</section>
226
+
227
+
<!-- /.intro -->
228
+
229
+
<!-- C usage documentation. -->
230
+
231
+
<sectionclass="usage">
232
+
233
+
### Usage
234
+
235
+
```c
236
+
#include"stdlib/stats/base/dstdevtk.h"
237
+
```
238
+
239
+
#### stdlib_strided_dstdevtk( N, correction, \*X, strideX )
240
+
241
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using a one-pass textbook algorithm.
242
+
243
+
```c
244
+
constdouble x[] = { 1.0, -2.0, 2.0 };
245
+
246
+
double v = stdlib_strided_dstdevtk( 3, 1.0, x, 1 );
247
+
// returns ~2.0817
248
+
```
249
+
250
+
The function accepts the following arguments:
251
+
252
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
253
+
- **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).
254
+
- **X**: `[in] double*` input array.
255
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dstdevtk_ndarray( N, correction, \*X, strideX, offsetX )
262
+
263
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using a one-pass textbook algorithm and alternative indexing semantics.
264
+
265
+
```c
266
+
constdouble x[] = { 1.0, -2.0, 2.0 };
267
+
268
+
double v = stdlib_strided_dstdevtk_ndarray( 3, 1.0, x, 1, 0 );
269
+
// returns ~2.0817
270
+
```
271
+
272
+
The function accepts the following arguments:
273
+
274
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
275
+
- **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).
276
+
- **X**: `[in] double*` input array.
277
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
278
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments