Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: statistics across multiple dimensions
Replies: 3   Last Post: Apr 20, 2011 7:01 PM

 Messages: [ Previous | Next ]
 Balachander Narasimhan Posts: 39 Registered: 2/4/08
Re: statistics across multiple dimensions
Posted: Apr 20, 2011 7:01 PM

Thanks. This works.

regs
bala

Doug Schwarz <see@sig.for.address.edu> wrote in message <see-DE124D.23454906042011@news.frontiernet.net>...
> In article
> TideMan <mulgor@gmail.com> wrote:
>

> > On Apr 7, 12:10 pm, "Balachander Narasimhan"
> > <balxxxxxch...@whatever.com> wrote:

> > > Hi,
> > >
> > > I have a 3D array. If I need the mean of all elements in two dimensions of
> > > this array, I can do something like
> > >
> > > mean(mean(a,1),2) to average over the first two dimensions of 3D array a
> > > lets say of size 5x5x5
> > >
> > > But I cannot do the same for variance. One of the options seems to be
> > >
> > > for k =1:5
> > > b = a(:,:,k);
> > > v(k) = var(reshape(b,25,1))
> > > end
> > >
> > > Is there a way to avoid this loop?

> >
> > You can do the same with var, only the dimension is the third
> > argument, not the second:
> > var(var(a,0,1),0,2)

>
> No, the mean of the mean is the mean of the whole matrix, but the
> variance of the variance is not the variance of the whole matrix.
>
> To the OP:
>
> a = rand(l,m,n);
> v = var(reshape(a,[],n));
>
> --
> Doug Schwarz
> dmschwarz&ieee,org
> Make obvious changes to get real email address.

Date Subject Author
4/6/11 Balachander Narasimhan
4/6/11 Derek Goring
4/6/11 Doug Schwarz
4/20/11 Balachander Narasimhan