Use Databin to Store Time Series
The arrival times in a PoissonProcess are independent and follow an ExponentialDistribution. You can simulate a path of a PoissonProcess by sending signals to a Databin in time intervals specified by a simulation of an exponential distribution.
In[1]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_102.png)
SeedRandom["11"];
\[Lambda] = 0.5;
times = RandomVariate[ExponentialDistribution[\[Lambda]], 30];
Create a Databin.
In[2]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_103.png)
bin = CreateDatabin[]
Use the simulated times to send 1 to the databin in time intervals.
In[3]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_104.png)
Table[DatabinAdd[bin, <|"arrivals" -> 1|>]; Pause[t], {t, times}];
The recorded signal with the time stamps.
In[4]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_105.png)
TimeSeries[bin]
Out[4]=
![](assets.en/use-databin-to-store-time-series/O_55.png)
Extract the TimeSeries object.
In[5]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_106.png)
ts1 = TimeSeries[bin]["arrivals"]
Out[5]=
![](assets.en/use-databin-to-store-time-series/O_56.png)
This time series is irregularly sampled.
In[6]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_107.png)
RegularlySampledQ[ts1]
Out[6]=
![](assets.en/use-databin-to-store-time-series/O_57.png)
Assume TemporalRegularity so that Accumulate does not use interpolation to resample the time series with respect to the minimum time increment.
In[7]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_108.png)
ts2 = Accumulate[TimeSeries[ts1, TemporalRegularity -> True]]
Out[7]=
![](assets.en/use-databin-to-store-time-series/O_58.png)
In[8]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_109.png)
DateListStepPlot[ts2, Joined -> False, PlotTheme -> "Detailed"]
Out[8]=
![](assets.en/use-databin-to-store-time-series/O_59.png)
Estimate the PoissonProcess parameter from the signal and compare to the parameter of the ExponentialDistribution used to simulate time stamps.
In[9]:=
![Click for copyable input](assets.en/use-databin-to-store-time-series/In_110.png)
{FindProcessParameters[ts2, PoissonProcess[\[Mu]]], \[Lambda]}
Out[9]=
![](assets.en/use-databin-to-store-time-series/O_60.png)