repl.txt (2693B)
1 2 {{alias}}( N, x, stride ) 3 Computes the arithmetic mean of a double-precision floating-point strided 4 array, ignoring `NaN` values and using a two-pass error correction 5 algorithm. 6 7 The `N` and `stride` parameters determine which elements in `x` are accessed 8 at runtime. 9 10 Indexing is relative to the first index. To introduce an offset, use a typed 11 array view. 12 13 If `N <= 0`, the function returns `NaN`. 14 15 If every indexed element is `NaN`, the function returns `NaN`. 16 17 Parameters 18 ---------- 19 N: integer 20 Number of indexed elements. 21 22 x: Float64Array 23 Input array. 24 25 stride: integer 26 Index increment. 27 28 Returns 29 ------- 30 out: number 31 The arithmetic mean. 32 33 Examples 34 -------- 35 // Standard Usage: 36 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); 37 > {{alias}}( x.length, x, 1 ) 38 ~0.3333 39 40 // Using `N` and `stride` parameters: 41 > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN ] ); 42 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 43 > var stride = 2; 44 > {{alias}}( N, x, stride ) 45 ~0.3333 46 47 // Using view offsets: 48 > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] ); 49 > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); 50 > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); 51 > stride = 2; 52 > {{alias}}( N, x1, stride ) 53 ~-0.3333 54 55 {{alias}}.ndarray( N, x, stride, offset ) 56 Computes the arithmetic mean of a double-precision floating-point strided 57 array, ignoring `NaN` values and using a two-pass error correction algorithm 58 and alternative indexing semantics. 59 60 While typed array views mandate a view offset based on the underlying 61 buffer, the `offset` parameter supports indexing semantics based on a 62 starting index. 63 64 Parameters 65 ---------- 66 N: integer 67 Number of indexed elements. 68 69 x: Float64Array 70 Input array. 71 72 stride: integer 73 Index increment. 74 75 offset: integer 76 Starting index. 77 78 Returns 79 ------- 80 out: number 81 The arithmetic mean. 82 83 Examples 84 -------- 85 // Standard Usage: 86 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); 87 > {{alias}}.ndarray( x.length, x, 1, 0 ) 88 ~0.3333 89 90 // Using offset parameter: 91 > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] ); 92 > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); 93 > {{alias}}.ndarray( N, x, 2, 1 ) 94 ~-0.3333 95 96 See Also 97 -------- 98