1
$\begingroup$

I'm having trouble with applying Accumulate to TimeSeries data as below

enter image description here

The results of the first call to Accumulate is wrong in length, 4 instead of 5 and value. Is this a bug? It certainly seems so to me, since if I replace T = septimes[[1;;5]] by T=Range[5] all is well. I'm running Mathematica 12.0 on OS X 10.11.6 (El Capitan)

$\endgroup$
1
  • 3
    $\begingroup$ I cannot reproduce your problem on my side with made up numbers. You should really include your code as text, with data and definitions. Pictures do not help us troubleshoot. $\endgroup$
    – MarcoB
    May 1 '20 at 15:37
7
$\begingroup$

The problem is that your time samples are not regularly sampled. When time intervals are unequal, Accumulate resamples to make a regularly sample series. See the "Possible Issues" section of Time Series documentation for an example similar to your data.

You can make Accumulate assume regular sampling with the TemporalRegularity option.

Values[Accumulate[TimeSeries[s, TemporalRegularity -> True]]]
{-10,-30,-10,-30,-50}
$\endgroup$
1
  • $\begingroup$ thanks that explains things perfectly $\endgroup$
    – Nick
    May 1 '20 at 18:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.