Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
4th order moments matrix from covariance matrix

Subject: 4th order moments matrix from covariance matrix

From: Elena

Date: 2 Apr, 2009 10:47:01

Message: 1 of 7

I want to calculate the matrix of the fourth order moments of some variables with normal distribution. If I have the covariance matrix but I don't have the values of the variables, can i construct the matrix I am looking for? Plus, I know that if I have n variables, the dimensions of covariance matrix are n x n and for the 4th-order-moments matrix are n^2 x n^2 and that the 3d-order-moments of a normal distribution are qual to zero. I also know that for a normal distribution, tha moments of 4th order can be substituted by the moments of second order: Nijkl=Mij*Mkl+Mik*Mjl+Mil*Mjk.

And my question is: what's the matlab code for the construction of this matrix? If, for example, I have 6 variables, I will really take a 36 x 36 matrix? I cannot understand the structure of the 4th-order-moments matrix....

Thank you in advance,

Elena

Subject: 4th order moments matrix from covariance matrix

From: Roger Stafford

Date: 2 Apr, 2009 15:30:19

Message: 2 of 7

"Elena " <elena.k29@hotmail.com> wrote in message <gr2535$pmo$1@fred.mathworks.com>...
> I want to calculate the matrix of the fourth order moments of some variables with normal distribution. If I have the covariance matrix but I don't have the values of the variables, can i construct the matrix I am looking for? Plus, I know that if I have n variables, the dimensions of covariance matrix are n x n and for the 4th-order-moments matrix are n^2 x n^2 and that the 3d-order-moments of a normal distribution are qual to zero. I also know that for a normal distribution, tha moments of 4th order can be substituted by the moments of second order: Nijkl=Mij*Mkl+Mik*Mjl+Mil*Mjk.
>
> And my question is: what's the matlab code for the construction of this matrix? If, for example, I have 6 variables, I will really take a 36 x 36 matrix? I cannot understand the structure of the 4th-order-moments matrix....
>
> Thank you in advance,
>
> Elena

  Why do you want to use an n^2 x n^2 two-dimensional matrix to store the 4th order moments? I would think a four-dimensional n x n x n x n array would be the most natural way to store these moments. If you did that, you could simply compute it with nested for-loops making a more or less direct use of the above formula:

 for i = 1:n
  for j = 1:n
   N(i,j,:,:) = M(i,j)*M + M(i,:).'*M(j,:) + M(j,:).'*M(i,:);
  end
 end

  Of course there is much redundancy in such storage. With the six-variable case you mentioned, the value for N(1,2,3,4), for example, will be duplicated 24 times in the 6 x 6 x 6 x 6 array. Much more compressed storage would therefore be possible, but it would be more complicated to access.

Roger Stafford

Subject: 4th order moments matrix from covariance matrix

From: Bruno Luong

Date: 2 Apr, 2009 16:28:01

Message: 3 of 7

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gr2lmb$b40$1@fred.mathworks.com>...
>
> Of course there is much redundancy in such storage. With the six-variable case you mentioned, the value for N(1,2,3,4), for example, will be duplicated 24 times in the 6 x 6 x 6 x 6 array. Much more compressed storage would therefore be possible, but it would be more complicated to access.

There is probably a simple to help for indexing.

Put all the combinaison of six-length vector sum to 4 in a array, then find where it is occurs. For example using allVL1 in FEX http://www.mathworks.com/matlabcentral/fileexchange/17818
function [ind map] = s2ind(sub, order)

% function [ind] = s2ind(sub)
% Return location IND of a sub (of length n) in the compact storage
% array of moments
% Use [maxind map] = s2ind(inf(1,n),order) to figure out the length of the
% compact moment array of length n and order order.
% Fast call: % [ind] = s2ind(sub, map)

n=length(sub);
if nargin<2
    order=sum(sub);
end

if ~isscalar(order)
    map = order; % fast call
else
    map = allVL1(n,order);
end

if any(isinf(sub)) || any(isnan(sub))
    ind=size(map,1);
else
    [tf ind]=ismember(sub,map,'rows');
end
end % s2ind

% Next use this w

n=6;
[maxind map]=s2ind(inf(1,6),4); % perform once
% maxind is 126, which is much smaller that 6^4= 1296

% Compute the moment
for k=1:maxind
   moment(map(k,:)) = ... % compute fourth moment like Roger's suggestion
end

% To find where to put moment of order [0 1 2 0 1 0]
loc = s2ind([0 1 2 0 1 0])
%
moment(loc)

% Bruno

Subject: 4th order moments matrix from covariance matrix

From: Elena

Date: 2 Apr, 2009 16:57:01

Message: 4 of 7

Thank your for your replies! I will study everything you told me.

Let's forget the case of 6 variables and let's consider tha general case,where I have n variables and I compute the covariance matrix (n x n). Using the matlab funuction "size" I can find n. How can I compute the 4th-order-moments matrix now?Can someone write the matlab code according to the equation I gave you?

The matrix should be 2-dimensional n^2 x n^2 because I have to multiply it with another matrix of the same dimensions.

Thank you very much guys...

Subject: 4th order moments matrix from covariance matrix

From: Roger Stafford

Date: 2 Apr, 2009 17:47:01

Message: 5 of 7

"Elena " <elena.k29@hotmail.com> wrote in message <gr2qot$a9m$1@fred.mathworks.com>...
> ......
> The matrix should be 2-dimensional n^2 x n^2 because I have to multiply it with another matrix of the same dimensions.
> ......

  If you are going to use an n^2 x n^2 4-th order moment matrix in some kind of matrix multiplication, the arrangement of moment values within it would presumably be of considerable importance. I would say the burden of deciding just how such a matrix is to be arranged is therefore up to you, Elena. How do you want it arranged? What 4-th order moment do you want located at the p-th row and q-th column of this two-dimensional moment matrix? We can't make that decision for you! We don't know how you are going to use it.

Roger Stafford

Subject: 4th order moments matrix from covariance matrix

From: Elena

Date: 2 Apr, 2009 18:42:02

Message: 6 of 7

First of all,thanks for your time!

You are right, I will study the equation that uses the matrix because it's a little bit complicated and I 'll be back...

Subject: 4th order moments matrix from covariance matrix

From: utc

Date: 15 May, 2013 10:45:09

Message: 7 of 7

If I note by Sig the covariance matrix and M4X the fourth oder moments matrix of gaussian vector then
M4= (K+I)*kron(Sig,Sig)+ Sig(:)*Sig(:)' (is a p^2 matrix dimension)

With K is a commutation matrix defined by K=sum_(i,j=1)^p kron(eiej',ejei'), ei is a base of space.

and I =eye(p^2);




"Elena" wrote in message <gr2535$pmo$1@fred.mathworks.com>...
> I want to calculate the matrix of the fourth order moments of some variables with normal distribution. If I have the covariance matrix but I don't have the values of the variables, can i construct the matrix I am looking for? Plus, I know that if I have n variables, the dimensions of covariance matrix are n x n and for the 4th-order-moments matrix are n^2 x n^2 and that the 3d-order-moments of a normal distribution are qual to zero. I also know that for a normal distribution, tha moments of 4th order can be substituted by the moments of second order: Nijkl=Mij*Mkl+Mik*Mjl+Mil*Mjk.
>
> And my question is: what's the matlab code for the construction of this matrix? If, for example, I have 6 variables, I will really take a 36 x 36 matrix? I cannot understand the structure of the 4th-order-moments matrix....
>
> Thank you in advance,
>
> Elena

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us