[Kst] plotting cumulative sum of vector

Nicolas Brisset nicolas.brisset at free.fr
Thu Sep 13 19:38:49 UTC 2012


Hi Mark,

sorry it took so long to answer, we're usually much faster. But somehow your mail disappeared under a pile of new messages...
> I want to create a plot of all elements of a vector cumulatively
> summed
> up to see the overall trend:
> Old Vector: 1,2,-3,6,9,...
> Plotted New Vector: 1,3,0,6,15,...
> Can this be achieved with KST2 and how ?
Yes
> I found the Cumulative Sum plugin, but that returns a scalar and not
> a vector.
The Cumulative Sum plugin is correct and should return a vector. I have just tested it and it works if you select a step of 1.0 as each new point is computed as previous_sum + step*new_point.
It seems that the default step is 0.0, which is not really good. I'll change it.
The only "problem" is that the returned vector has a size of n+1 (the first point being 0.0), so if you plot it against the same x vector as the origin vector the curve will have interpolated points.
I wonder whether the first point should not be the same as the first point of the input vector to keep the size the same. Does anybody have objections or can I make that change?

Nicolas


More information about the Kst mailing list