1

Matlabで2次元の離散分布(N²-> R)を与える行列があります。

Matlab(R2011b、統計ツールボックス付き)に中心モーメントと平均を与える組み込み関数はありますか?(R²-> R)の関数に存在する場合も問題ありません。そうでなければ、私はそれらを自分で構築する必要がありますが、私は車輪の再発明をしたくありません。

ありがとうございました

4

1 に答える 1

2

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:

    % x=1  x=2  x=3
P = [ 0.1  0.2  0.1        % y = 1  
      0.1  0.1  0.2        % y = 2
      0.0  0.0  0.2 ]      % y = 3

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 N in mathematical notation means the natural numbers. If so, then you can use the following code.

Mean:

 meanX = sum(P,1) * (1:size(P,2))'; 
 meanY = sum(P,2)' * (1:size(P,1))';

For the central moment K,L (K correspnding to X and L corresponding to Y):

 [X,Y] = meshgrid(1:size(P,2),1:size(P,1));
 integrandXY_KL = (X - meanX).^K .* (Y-meanY).^L .* P;
 momentXY_KL = sum(integrandXY_KL(:));

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 ] and Yvals = [ 4 5 6 ]. All of the above still works, you just replace all occurences of 1:size(P,2) with Xvals and all occurences of 1:size(P,1) with Yvals.

于 2012-06-19T00:34:13.237 に答える