I didn't see this coming:


randomTimeSeries[seed_ : RandomInteger[{10^6, 10^7}], m_ : 3, n_ : 30,iRandRng_ : {1, 7}] :=     
    Module[{ds, vs, junk, ts},
      {junk, {ts}} = Do[
          ds = NestList[(DatePlus[#, -RandomInteger[iRandRng]] &), AbsoluteTime[], n - 1] // Reverse;
          vs = RandomReal[{0, 1}, n] // Accumulate;
          TimeSeries[vs, {ds}, ResamplingMethod -> {"Interpolation", 0}, MetaInformation -> {"seed" -> seed + j}] // Quiet /* Sow, 
            RandomSeeding -> seed + j], {j, 1, m}] // Reap;
      ts // (TimeSeriesThread[Mean, #] &)

Every single time I evaluate randomTimeSeries[RandomInteger[{10^6, 10^7}]] // Accumulate I get

  1. Error messages about interpolation even though I am using Quiet
  2. High memory and CPU usage and
  3. The Kernel quits with messages about there being insufficient memory

I'm on Win10, using v.12.1.

Does anybody know whats going on ?

  • $\begingroup$ What are your thoughts? $\endgroup$ Commented Apr 20, 2020 at 18:01
  • $\begingroup$ If you remove the Accumulate, you get the warnings (they're not errors, they are warning you that its extrapolating, not interpolating) and a time series object. Maybe look carefully at the time series object to see why it is causing problems... $\endgroup$
    – bill s
    Commented Apr 20, 2020 at 18:08
  • $\begingroup$ @bills shouldn't there be no messages since I'm using Quiet? It really threw my schedule out the window today but I think the problem is due to the fact that there are non-regular series involved; using TemporalRegularity->True seems to make the Kernel happy $\endgroup$
    – user42582
    Commented Apr 20, 2020 at 19:56

1 Answer 1


This is as designed. If we set

ts = randomTimeSeries[RandomInteger[{10^6, 10^7}]]

then RegularlySampledQ[ts] is False which means that calling Accumulate on it will first trigger TimeSeriesResample on ts with respect to the minimal time step:

In[3]:= ts["MinimumTimeIncrement"]

Out[3]= {0.00926208}

which is very small compared to the other time increments:

In[5]:= Differences[ts["Times"]] // MinMax

Out[5]= {0.00926208, 432000.}

and hence the huge memory usage and hang and/or crash.

If the objective is to accumulate values only then either call Accumulate on ts["Values"] or create new TimeSeries object that forces TemporalRegularity to True and then apply Accumulate:

In[6]:= ts1 = TimeSeries[ts, TemporalRegularity -> True];

In[9]:= (Accumulate[ts1] // Head) // AbsoluteTiming

Out[9]= {0.000467, TemporalData}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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