From octave-sources-request at bevo dot che dot wisc dot edu Thu Apr 15 23:49:16 1999 Subject: more semi-lame code... From: doolin at alpha-8 dot CE dot Berkeley dot EDU To: octave-sources at bevo dot che dot wisc dot edu Cc: doolin at alpha-8 dot CE dot Berkeley dot EDU Date: Thu, 15 Apr 1999 21:49:12 -0700 Attached is a minor utility to compute cumulative averages. I did not find anything like this in 2.1.13 scripts. I am willing to write texi docs along with any code I submit, but it would help to have the docs already distributed be up to date. The 2.1.13 docs appear to be a bit short wrt to the code available. At some point I will be printing out the entire 300 pages, which is sequentially numbered. Are there any arguments against section or chapter numbering? This would help cut down printing when there is a major change. % function averages = cumaverage(input) % % Computes a cumulative average of values in a row vector. % % input: x: row vector. % % output: averages: column vector of successive % cumulative averages. % % example: Running this should be self-explanatory. % octave:40> testem = randn(1,200); % octave:41> a = cumaverage (testem); % octave:42> plot (a) % % bugs and limitations: Should be extended to handle a % matrix instead of a column vector. % This script probably belongs in octave/statistics/base % % This code is copyright David M. Doolin under the GNU % General Public License (GPL). This program is distributed % in the hope that it will be useful, but WITHOUT ANY WARRANTY; % without even the implied warranty of MERCHANTABILITY or % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public % License for more details. You should have received a % copy of the GNU General Public License along with this file. % If not, write to the Free Software Foundation, % 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. % % $Author: doolin $ doolin at ce dot berkeley dot edu % $Date: 1999/04/16 04:40:24 $ % $Source: /shag/homes/doolin/cvsroot/octave/statistics/cumaverage.m,v $ % $Revision: 1.5 $ 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