I have got a matrix which gives me a 2-dimensional discrete distribution (N²->R) in Matlab.
Are there built-in functions in Matlab (R2011b, with the statistic toolbox) giving the central moments and the mean? If they exist for functions of (R²->R) it is fine too. Otherwise I will have to build them myself, but I don’t want to reinvent the wheel.
Thank you
A quick look and I couldn’t turn up any functions, though this isn’t a fact by any means.
However, working it out from scratch, and assuming you mean a matrix such as:
And you mean that this describes the joint discrete distribution (joint probability mass function). That is, the entry at
(X,Y)contains the probability of(X,Y)occurring.I’m also assuming by your use of
Nin mathematical notation means the natural numbers. If so, then you can use the following code.Mean:
For the central moment
K,L(Kcorrespnding toXandLcorresponding toY):And you can generalize it further if the values of X are arbitrary (and not just natural numbers) as follows. If
Xvals = [ 1 2 4 ]andYvals = [ 4 5 6 ]. All of the above still works, you just replace all occurences of1:size(P,2)withXvalsand all occurences of1:size(P,1)withYvals.