Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Bogey
Date: Wed, 29 Oct 2008 20:25:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <geagqv$hmv$1@fred.mathworks.com>
References: <gdvjlp$kij$1@fred.mathworks.com> <gdvoje$gnn$1@fred.mathworks.com> <gdvq28$482$1@fred.mathworks.com> <ge0231$lu$1@fred.mathworks.com> <ge2b76$msj$1@fred.mathworks.com> <ge2dju$bjg$1@fred.mathworks.com> <ge2jbm$q98$1@fred.mathworks.com> <ge2lf8$dbb$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225311903 18143 172.30.248.38 (29 Oct 2008 20:25:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 29 Oct 2008 20:25:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:497880


"b b" <bogey4@gmail.com> wrote in message <ge2lf8$dbb$1@fred.mathworks.com>...
> Thanks Bruno,
> 
> I'm still wrapping my head around how this works, but the results are correct.  FYI, on a slightly larger dataset (N=137 vs N=4), the times are a bit faster with the loop method, although I was more interested in learning to program without loops, so this is great.
> 
> Elapsed time is 0.004989 seconds. (Loop)
> Elapsed time is 0.008515 seconds.(ndgrid)
> 
> Bruce

Hello Bruce,

  Try the following, which expands the square operation:

tot = sum(X.^2,1)*sum(ksi,2)-2*sum(sum((X*ksi).*muEst))...
     +sum(sum(ksi,1).*sum(muEst.^2,1));

  I can't speak for its execution speed, but its intermediate matrices are smaller in size than that produced using the 'ndgrid' method.

Roger Stafford