Reputation: 23
maybe I miss the obvious, but how do I get the mean value of the following matrix ?
matrix( [ , , ],
[7.5133, , 5.3 ],
[4.93 , 5.7667 , 2.9067 ] );
I tried mean, geometric_mean, ... and the other commands from the descriptive package, but they don't work with missing values.
regards, Marcus
Upvotes: 2
Views: 84
Reputation: 5768
I think one have to implement it. For example
M: matrix(
[ und , und, und],
[7.5133, und, 5.3],
[4.93 , 5.7667 , 2.9067] ) $
ulength(x):=block([n: 0], matrixmap(lambda([e], if e#'und then n: n + 1), x), n) $
usum(x):=block([s: 0], matrixmap(lambda([e], if e#'und then s: s + e), x), s) $
umean(x):=usum(x)/ulength(x) $
umean(M);
Upvotes: 1