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`,
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 sstdev =require( '@stdlib/stats/base/sstdev' );
209
198
210
-
var x;
211
-
var i;
212
-
213
-
x =newFloat32Array( 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':'float32'
201
+
});
217
202
console.log( x );
218
203
219
204
var v =sstdev( x.length, 1, x, 1 );
@@ -224,10 +209,129 @@ console.log( v );
224
209
225
210
<!-- /.examples -->
226
211
212
+
<!-- C interface documentation. -->
213
+
227
214
* * *
228
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/sstdev.h"
236
+
```
237
+
238
+
#### stdlib_strided_sstdev( N, correction, \*X, strideX )
239
+
240
+
Computes the [standard deviation][standard-deviation] of a single-precision floating-point strided array.
- **N**: `[in] CBLAS_INT` number of indexed elements.
252
+
- **correction**: `[in] float` 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] float*` input array.
254
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
float v = stdlib_strided_sstdev_ndarray( 4, 1.0f, x, 2, 0 );
268
+
// returns 2.581989f
269
+
```
270
+
271
+
The function accepts the following arguments:
272
+
273
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
274
+
- **correction**: `[in] float` 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] float*` input array.
276
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
277
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
float v = stdlib_strided_sstdev( N, 1.0f, x, strideX );
317
+
318
+
// Print the result:
319
+
printf( "sample standard deviation: %f\n", v );
320
+
}
321
+
```
322
+
323
+
</section>
324
+
325
+
<!-- /.examples -->
326
+
327
+
</section>
328
+
329
+
<!-- /.c -->
330
+
229
331
<section class="references">
230
332
333
+
* * *
334
+
231
335
## References
232
336
233
337
- Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958][@neely:1966a].
0 commit comments