|
| 1 | + |
| 2 | +{{alias}}( fcn, arrays, dims[, options] ) |
| 3 | + Performs a reduction over a list of specified dimensions in an input ndarray |
| 4 | + via a one-dimensional strided array reduction function and assigns results |
| 5 | + to a provided output ndarray. |
| 6 | + |
| 7 | + Each provided "ndarray" should be an object with the following properties: |
| 8 | + |
| 9 | + - dtype: data type. |
| 10 | + - data: data buffer. |
| 11 | + - shape: dimensions. |
| 12 | + - strides: stride lengths. |
| 13 | + - offset: index offset. |
| 14 | + - order: specifies whether an ndarray is row-major (C-style) or column-major |
| 15 | + (Fortran-style). |
| 16 | + |
| 17 | + The output ndarray and any additional ndarray arguments are expected to have |
| 18 | + the same dimensions as the non-reduced dimensions of the input ndarray. When |
| 19 | + calling the reduction function, any additional ndarray arguments are |
| 20 | + provided as zero-dimensional ndarray-like objects. |
| 21 | + |
| 22 | + Parameters |
| 23 | + ---------- |
| 24 | + fcn: Function |
| 25 | + Function which will be applied to a one-dimensional subarray and should |
| 26 | + store reduction results in an output struct object. The function should |
| 27 | + have the following signature: |
| 28 | + |
| 29 | + fcn( arrays[, options] ) |
| 30 | + |
| 31 | + where |
| 32 | + |
| 33 | + - arrays: array containing a one-dimensional subarray of the input |
| 34 | + ndarray, a zero-dimensional subarray of the output ndarray containing |
| 35 | + the output struct object, and any additional ndarray arguments as zero- |
| 36 | + dimensional ndarrays. |
| 37 | + - options: function options. |
| 38 | + |
| 39 | + arrays: ArrayLikeObject<ndarray> |
| 40 | + Array-like object containing one input ndarray and one output ndarray, |
| 41 | + followed by any additional ndarray arguments. |
| 42 | + |
| 43 | + dims: Array<integer> |
| 44 | + List of dimensions over which to perform a reduction. |
| 45 | + |
| 46 | + options: Object (optional) |
| 47 | + Function options. |
| 48 | + |
| 49 | + Examples |
| 50 | + -------- |
| 51 | + // Define ndarray data and meta data... |
| 52 | + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); |
| 53 | + > var dtype = 'float64'; |
| 54 | + > var shx = [ 2, 2 ]; |
| 55 | + > var sx = [ 2, 1 ]; |
| 56 | + > var ox = 0; |
| 57 | + > var order = 'row-major'; |
| 58 | + |
| 59 | + > var F64 = {{alias:@stdlib/stats/base/ztest/one-sample/results/float64}}; |
| 60 | + > var ResultsArray = {{alias:@stdlib/dstructs/struct}}( F64 ); |
| 61 | + > var ybuf = new ResultsArray( 1 ); |
| 62 | + > var shy = []; |
| 63 | + > var sy = [ 0 ]; |
| 64 | + > var oy = 0; |
| 65 | + |
| 66 | + // Using minimal ndarray-like objects... |
| 67 | + > var x = { |
| 68 | + ... 'dtype': dtype, |
| 69 | + ... 'data': xbuf, |
| 70 | + ... 'shape': shx, |
| 71 | + ... 'strides': sx, |
| 72 | + ... 'offset': ox, |
| 73 | + ... 'order': order |
| 74 | + ... }; |
| 75 | + > var y = { |
| 76 | + ... 'dtype': F64, |
| 77 | + ... 'data': ybuf, |
| 78 | + ... 'shape': shy, |
| 79 | + ... 'strides': sy, |
| 80 | + ... 'offset': oy, |
| 81 | + ... 'order': order |
| 82 | + ... }; |
| 83 | + > var alt = { |
| 84 | + ... 'dtype': 'generic', |
| 85 | + ... 'data': [ 'two-sided' ], |
| 86 | + ... 'shape': shy, |
| 87 | + ... 'strides': [ 0 ], |
| 88 | + ... 'offset': 0, |
| 89 | + ... 'order': order |
| 90 | + ... }; |
| 91 | + > var alpha = { |
| 92 | + ... 'dtype': 'generic', |
| 93 | + ... 'data': [ 0.05 ], |
| 94 | + ... 'shape': shy, |
| 95 | + ... 'strides': [ 0 ], |
| 96 | + ... 'offset': 0, |
| 97 | + ... 'order': order |
| 98 | + ... }; |
| 99 | + > var mu = { |
| 100 | + ... 'dtype': 'generic', |
| 101 | + ... 'data': [ 0.0 ], |
| 102 | + ... 'shape': shy, |
| 103 | + ... 'strides': [ 0 ], |
| 104 | + ... 'offset': 0, |
| 105 | + ... 'order': order |
| 106 | + ... }; |
| 107 | + > var sigma = { |
| 108 | + ... 'dtype': 'generic', |
| 109 | + ... 'data': [ 1.0 ], |
| 110 | + ... 'shape': shy, |
| 111 | + ... 'strides': [ 0 ], |
| 112 | + ... 'offset': 0, |
| 113 | + ... 'order': order |
| 114 | + ... }; |
| 115 | + > var f = {{alias:@stdlib/stats/base/ndarray/ztest}}; |
| 116 | + > {{alias}}( f, [ x, y, alt, alpha, mu, sigma ], [ 0, 1 ] ); |
| 117 | + > y.data.get( 0 ).toString() |
| 118 | + <string> |
| 119 | + |
| 120 | + See Also |
| 121 | + -------- |
| 122 | + |
0 commit comments