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