Recently, I have been trying to simulate a random/stochastic variable that follows Gaussian distribution and also has an exponential correlation function $\left\langle X(t)X(s)\right\rangle= e^{-\frac{|t-s|}{tc}}$. Through many interesting posts from Stack, I realized the function I was looking was the OrnsteinUhlenbeckProcess.
Accordingly, I created the following code to simulate my random variable $X(t)$ using a useful post Continuous noise representation
ti = 0;
tf = 100;
tc = 1;
dt = .1;
(*analytical correlation*)
corrana[t_]:=CorrelationFunction[OrnsteinUhlenbeckProcess[0,1/10,1/tc],0,t]
(*defining variable*)
X = Interpolation[Normal[RandomFunction[OrnsteinUhlenbeckProcess[0, 1/10, 1/tc],{ti,tf,dt}]][[1]]];
data = Table[X[t], {t, ti, tf, dt}];
{Plot[X[t], {t, ti, tf}], Histogram[data]}
corr = ListPlot[{CorrelationFunction[data, {IntegerPart[tf/dt]}],Table[{t, corrana[t]}, {t, ti, tf, dt}]}, PlotRange -> {Automatic, All}, PlotLegends -> {"From data", "From model"}, Joined -> True, AxesLabel -> {"t", "Correlation"}, PlotStyle -> {Orange, Black}];
Show[corr, PlotRange -> {{0, (3/10)*f/dt}, All}]
First, we can see that the histogram presents the Gaussian character of my variable
Additionally, the plot comparing the numerical and analytical calculation of the correlation function do also match to each other, but only for small times.
Accordingly to those features, I have some questions, namely:
Question 1: Why the numerical and analytical correlation functions only present a good aggreement for $t\lesssim tc$? Additionally, it seems there is a revival of the correlation for long times, which is evidenced by the oscillations of the numerical correlation functions around the $0$ value. Is this reasonable?
Question 2: The axis of the correlation function is not the real time but rather the position of the discrete time. How could I plot the numerical correlation as a function of the real time?