Re: Cumulative sum [message #33706] |
Thu, 16 January 2003 15:01 |
graves
Messages: 7 Registered: September 2001
|
Junior Member |
|
|
> Is there a function for computing the cumulative sum of
> an array (similar to matlab's cumsum)?
> For instance: cumsum(indgen(5)) = [1,3,6,10,15]
The IDL equivalent is to use the total function with the cumulative
keyword, so your example would be total(indgen(5), /cumulative).
Ted
|
|
|
Re: Cumulative sum [message #33709 is a reply to message #33706] |
Thu, 16 January 2003 13:26  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
rkj@dukebar.crml.uab.edu (R. Kyle Justice) writes:
> Thanks for the quick replies. However, I am using
> PV-Wave and the TOTAL function does not have a
> Cumulative keyword. I guess I will be looping . . .
Yes, and it's a fairly new keyword even in IDL. This is one area
where I have resorted to looping unfortunately.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Cumulative sum [message #33710 is a reply to message #33709] |
Thu, 16 January 2003 12:33  |
rkj
Messages: 66 Registered: February 1996
|
Member |
|
|
Thanks for the quick replies. However, I am using
PV-Wave and the TOTAL function does not have a
Cumulative keyword. I guess I will be looping . . .
Kyle
|
|
|
Re: Cumulative sum [message #33711 is a reply to message #33710] |
Thu, 16 January 2003 12:14  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
"R. Kyle Justice" <rkj@dukebar.crml.uab.edu> wrote in message
news:b072o8$6j0$1@SonOfMaze.dpo.uab.edu...
> Is there a function for computing the cumulative sum of
> an array (similar to matlab's cumsum)?
>
> For instance: cumsum(indgen(5)) = [1,3,6,10,15]
>
> Kyle J.
See the CUMULATIVE keyword for the TOTAL function:
"If this keyword is set, the result is an array of the same size as the
input, with each element, i, containing the sum of the input array elements
0 to i. This keyword also works with the Dimension parameter, in which case
the sum is performed over the given dimension."
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
Re: Cumulative sum [message #33712 is a reply to message #33711] |
Thu, 16 January 2003 12:14  |
mchinand
Messages: 66 Registered: September 1996
|
Member |
|
|
In article <b072o8$6j0$1@SonOfMaze.dpo.uab.edu>,
R. Kyle Justice <rkj@dukebar.crml.uab.edu> wrote:
> Is there a function for computing the cumulative sum of
> an array (similar to matlab's cumsum)?
>
> For instance: cumsum(indgen(5)) = [1,3,6,10,15]
>
> Kyle J.
>
>
Yes, use the /CUMULATIVE keyword to TOTAL. With the optional DIMENSION
argument can set over which dimension is summed over.
--Mike
--
Michael Chinander
m-chinander@uchicago.edu
Department of Radiology
University of Chicago
|
|
|