```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Recursive mean plot
Date: Mon, 5 Dec 2011 06:12:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <jbhnbo\$rr0\$1@newscl01ah.mathworks.com>
References: <jbdnpt\$25m\$1@newscl01ah.mathworks.com> <jbh6fo\$aqv\$1@newscl01ah.mathworks.com> <b62829cd-63c9-4815-94a0-f9d9b09e41aa@z1g2000yqa.googlegroups.com>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1323065528 28512 172.30.248.35 (5 Dec 2011 06:12:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Dec 2011 06:12:08 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:751428

Greg Heath <heath@alumni.brown.edu> wrote in message <b62829cd-63c9-4815-94a0-f9d9b09e41aa@z1g2000yqa.googlegroups.com>...
> Is there a similar vectorization for the variance?
- - - - - - - - - - -
Hi Greg.  I don't really know how a recursive variance is defined, but if it is analogous to this recursive mean, you could use:

n = length(Z);
V = (cumsum(Z.^2)-cumsum(Z).^2./(1:n).')./[1;(1:n-1).'];

(For large n this form suffers somewhat from greater round off error.)

Roger Stafford
```