Library: | xplore |
See also: | prod prodex |
Quantlet: | cumprodex | |
Description: | an extended form of the cumprod function - NaN and all values contained in excl are excluded from computation |
Usage: | cprodx = cumprodex(x{, excl {, s}}) | |
Input: | ||
x | d1 x d2 x .. x dn array, n <= 7 | |
excl | a matrix containing values to be excluded | |
s | integer (number of dimension, default = 1) | |
Output: | ||
cprodx | d1 x d2 x .. x d(j-1) x 1 x d(j+1) x .. x dn array |
library("xplore") randomize(666) x = rint(10 * uniform(5, 4)) x[2,1] = NaN x excl = #(2,4) cumprodex(x,excl)
Contents of x [1,] 3 9 5 3 [2,] +NAN 4 2 6 [3,] 1 2 7 8 [4,] 9 5 5 1 [5,] 7 1 3 5 Contents of cprodx [1,] 3 9 5 3 [2,] +NAN -NAN -NAN 18 [3,] 3 -NAN 35 144 [4,] 27 45 175 144 [5,] 189 45 525 720