repl.txt (4003B)
1 2 {{alias}}( N, correction, x, stride ) 3 Computes the standard deviation of a strided array ignoring `NaN` values and 4 using Welford's algorithm. 5 6 The `N` and `stride` parameters determine which elements in `x` are accessed 7 at runtime. 8 9 Indexing is relative to the first index. To introduce an offset, use a typed 10 array view. 11 12 If `N <= 0`, the function returns `NaN`. 13 14 If every indexed element is `NaN`, the function returns `NaN`. 15 16 Parameters 17 ---------- 18 N: integer 19 Number of indexed elements. 20 21 correction: number 22 Degrees of freedom adjustment. Setting this parameter to a value other 23 than `0` has the effect of adjusting the divisor during the calculation 24 of the standard deviation according to `N - c` where `c` corresponds to 25 the provided degrees of freedom adjustment. When computing the standard 26 deviation of a population, setting this parameter to `0` is the standard 27 choice (i.e., the provided array contains data constituting an entire 28 population). When computing the corrected sample standard deviation, 29 setting this parameter to `1` is the standard choice (i.e., the provided 30 array contains data sampled from a larger population; this is commonly 31 referred to as Bessel's correction). 32 33 x: Array<number>|TypedArray 34 Input array. 35 36 stride: integer 37 Index increment. 38 39 Returns 40 ------- 41 out: number 42 The standard deviation. 43 44 Examples 45 -------- 46 // Standard Usage: 47 > var x = [ 1.0, -2.0, NaN, 2.0 ]; 48 > {{alias}}( x.length, 1, x, 1 ) 49 ~2.0817 50 51 // Using `N` and `stride` parameters: 52 > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; 53 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 54 > {{alias}}( N, 1, x, 2 ) 55 ~2.0817 56 57 // Using view offsets: 58 > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); 59 > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); 60 > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); 61 > {{alias}}( N, 1, x1, 2 ) 62 ~2.0817 63 64 {{alias}}.ndarray( N, correction, x, stride, offset ) 65 Computes the standard deviation of a strided array ignoring `NaN` values and 66 using Welford's algorithm and alternative indexing semantics. 67 68 While typed array views mandate a view offset based on the underlying 69 buffer, the `offset` parameter supports indexing semantics based on a 70 starting index. 71 72 Parameters 73 ---------- 74 N: integer 75 Number of indexed elements. 76 77 correction: number 78 Degrees of freedom adjustment. Setting this parameter to a value other 79 than `0` has the effect of adjusting the divisor during the calculation 80 of the standard deviation according to `N - c` where `c` corresponds to 81 the provided degrees of freedom adjustment. When computing the standard 82 deviation of a population, setting this parameter to `0` is the standard 83 choice (i.e., the provided array contains data constituting an entire 84 population). When computing the corrected sample standard deviation, 85 setting this parameter to `1` is the standard choice (i.e., the provided 86 array contains data sampled from a larger population; this is commonly 87 referred to as Bessel's correction). 88 89 x: Array<number>|TypedArray 90 Input array. 91 92 stride: integer 93 Index increment. 94 95 offset: integer 96 Starting index. 97 98 Returns 99 ------- 100 out: number 101 The standard deviation. 102 103 Examples 104 -------- 105 // Standard Usage: 106 > var x = [ 1.0, -2.0, NaN, 2.0 ]; 107 > {{alias}}.ndarray( x.length, 1, x, 1, 0 ) 108 ~2.0817 109 110 // Using offset parameter: 111 > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; 112 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 113 > {{alias}}.ndarray( N, 1, x, 2, 1 ) 114 ~2.0817 115 116 See Also 117 -------- 118