1
$\begingroup$

I am working with the following differential equation:

The equation is $$x=\beta +\sqrt{2D} \xi(t)$$ where $\xi(t)$ is a white noise term, with a reflecting wall boundary conditions.

After solving the equation numerically with Euler-Maruyama method, I used the Wiener-Khinchin theorem (Using FFT) to find a numerical solution for the correlation function. My problem is, get every time a new starting point for the correlation function even for exactly the same parameters, no matter how I change the parameters, and I am sure of my code because I have tried it on Orstein-Uhlenbeck and the results were right.

What is the problem of the varying starting points, or what did I misunderstand about correlation functions that is leading to this ?? (Please see the code below, and the plots of the correlation function for the same given parameters) Correlation function of the SDE Another correlation function for the same SDE with exactly the same parameteres another example of the same simulation of the correlation function

This is the code for simulating the SDE with Euler method and simulating the correlation function

 N = 8192
dt = 0.3
T = N*dt
time = np.arange(N)*dt
gamma = 0.1
D=1
v_factor = math.sqrt(2*D*dt)
v_data = []

v=1

###Eurler method to solve the SDE
for t in range(50000):  ##This part just to make sure we get the stationary process
        F = random.gauss(0,1)
        v = v - gamma*dt + v_factor*F
        if v<0:
            v=-v
for t in range(N):
        F = random.gauss(0,1)
        v = v - gamma*dt + v_factor*F
        if v<0:
            v=-v
        v_data.append(v)
# Compute numerically the autocorrelation via a Fourier transform

fft_cor = scipy.signal.fftconvolve(v_data, v_data[::-1])[N-1:]
fft_cor /= (N - np.arange(N))
plt.plot(time, fft_cor, 'k-', lw=2,label="Fourier-Transform")


# Compute the autocorrelation via the Wiener-Khinchin theorem

psd = np.fft.fft(v_data)*np.conj(np.fft.fft(v_data))/N
C = np.fft.ifft(psd).real

plt.plot(time, C,label='Wiener-Khinchin theorem')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.