From octave-sources-request at bevo dot che dot wisc dot edu Fri Apr 16 03:48:25 1999 Subject: Re: more semi-lame code... From: Francesco Potorti` To: doolin at alpha-8 dot CE dot Berkeley dot EDU CC: octave-sources at bevo dot che dot wisc dot edu Date: Fri, 16 Apr 1999 10:45:34 +0200 (CEST) Attached is a minor utility to compute cumulative averages. function av = cumaverage(x) warn_empty_list_ok = 1; av = []; c = columns(x); for j = 1:c av = [av, sum(x(1,1:j))/j]; end endfunction Doing like this should be hundredths of times faster for long vectors: cumaverage = cumsum(x) ./ [1:lenght(x)]; -- Francesco Potort́ (researcher) Voice: +39-050-593 203 (op. 211) Computer Networks Group Fax: +39-050-904052 CNUCE-CNR, Via Santa Maria 36 Email: F dot Potorti at cnuce dot cnr dot it 56126 Pisa - Italy Web: http://fly.cnuce.cnr.it/