[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cumulative mean
From: |
AlbFrigerio |
Subject: |
Re: Cumulative mean |
Date: |
Fri, 21 May 2010 04:59:18 -0700 (PDT) |
Francesco, you are right, but my problem is not how to find the cumulative
mean (I forgot the attached file, now you may see it) but only to know if
there is an Octave function which already makes it. As you can see in the
attached file I wrote a code calculating cumulative arithmetic, geometric
and harmonic mean of a vector or of a matrix (really simple, I'm not a
genious ;) ) , I just wanna know if I made something useful or not
(obviously if I could find an Octave function making cumulative means I
would use it!!) .
Alberto
http://n4.nabble.com/file/n2226039/cummean.m cummean.m
>Looking for something like cummax and cummin , is there a function to
>calculate the cumulative mean of a matrix / vector? I know it's an easy
>program to implement and I already made it on my own (as you may see in the
>attached file) , I just wanna know if there is a standard Octave function,
>which will be probably faster than mine.
I think that this is what you want:
octave> A=magic(4);A=horzcat(A,2*A)
A =
16 2 3 13 32 4 6 26
5 11 10 8 10 22 20 16
9 7 6 12 18 14 12 24
4 14 15 1 8 28 30 2
octave> cumsum(A)
ans =
16 2 3 13 32 4 6 26
21 13 13 21 42 26 26 42
30 20 19 33 60 40 38 66
34 34 34 34 68 68 68 68
octave> diag(1./(1:rows(A)))*cumsum(A)
ans =
16.0000 2.0000 3.0000 13.0000 32.0000 4.0000 6.0000
26.0000
10.5000 6.5000 6.5000 10.5000 21.0000 13.0000 13.0000
21.0000
10.0000 6.6667 6.3333 11.0000 20.0000 13.3333 12.6667
22.0000
8.5000 8.5000 8.5000 8.5000 17.0000 17.0000 17.0000
17.0000
--
Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
--
View this message in context:
http://octave.1599824.n4.nabble.com/Cumulative-mean-tp2225852p2226039.html
Sent from the Octave - General mailing list archive at Nabble.com.