repl.txt (1917B)
1 2 {{alias}}( W[, mx, my] ) 3 Returns an accumulator function which incrementally computes a moving 4 sample Pearson product-moment correlation distance. 5 6 The correlation distance is defined as one minus the Pearson product-moment 7 correlation coefficient and, thus, resides on the interval [0,2]. 8 9 However, due to limitations inherent in representing numeric values using 10 floating-point format (i.e., the inability to represent numeric values with 11 infinite precision), the correlation distance between perfectly correlated 12 random variables may *not* be `0` or `2`. In fact, the correlation distance 13 is *not* guaranteed to be strictly on the interval [0,2]. Any computed 14 distance should, however, be within floating-point roundoff error. 15 16 The `W` parameter defines the number of values over which to compute the 17 moving sample correlation distance. 18 19 If provided values, the accumulator function returns an updated moving 20 sample correlation distance. If not provided values, the accumulator 21 function returns the current moving sample correlation distance. 22 23 As `W` (x,y) pairs are needed to fill the window buffer, the first `W-1` 24 returned values are calculated from smaller sample sizes. Until the window 25 is full, each returned value is calculated from all provided values. 26 27 Parameters 28 ---------- 29 W: integer 30 Window size. 31 32 mx: number (optional) 33 Known mean. 34 35 my: number (optional) 36 Known mean. 37 38 Returns 39 ------- 40 acc: Function 41 Accumulator function. 42 43 Examples 44 -------- 45 > var accumulator = {{alias}}( 3 ); 46 > var d = accumulator() 47 null 48 > d = accumulator( 2.0, 1.0 ) 49 1.0 50 > d = accumulator( -5.0, 3.14 ) 51 ~2.0 52 > d = accumulator( 3.0, -1.0 ) 53 ~1.925 54 > d = accumulator( 5.0, -9.5 ) 55 ~1.863 56 > d = accumulator() 57 ~1.863 58 59 See Also 60 -------- 61