Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numerical Laplace transform python

I have a time series of experimental data x = x(t) in two numpy arrays, x for the observable and t for the time values of the observations. Is there a numpy function or a way that can evaluate the laplace transform of the timeseries? Thank you in advance.

like image 960
Mavridis M. Avatar asked Jul 11 '16 21:07

Mavridis M.


1 Answers

I think you should have to consider the Laplace Transform of f(x) as the Fourier Transform of Gamma(x)f(x)e^(bx), in which Gamma is a step function that delete the negative part of the integral and e^(bx) constitute the real part of the complex exponential. There is a well known algorithm for Fourier Transform known as "Fast Fourier Transform" (FFT), for which you can find a lot of tutorials on both Python and Matlab websites.

Here I give you a short code that calculate the Fourier transform of a step function such as y = 0 for |x| > 1 y = 1 for |x| < 1

for which the Fourier Transform can be analitically calculated as sin(pix) / (pix).

import matplotlib.pyplot as plt
import scipy
from scipy.fftpack import fftshift
import numpy as np

x = np.arange(-3, 3, 0.01)
y = np.zeros(len(x))
y[150:450] = 1
plt.plot(x, y) # plot of the step function

yShift = fftshift(y) # shift of the step function
Fourier = scipy.fft(yShift) # Fourier transform of y implementing the FFT
Fourier = fftshift(Fourier) # inverse shift of the Fourier Transform
plt.plot(Fourier) # plot of the Fourier transform

Note that before and after applying the Fast Fourier Transform you have to use the fftshift command that provide a shift of the left side of the plot to the right side and viceversa. This is not the complete answer to your question, but I believe that is a good start.

like image 165
Stefano Fedele Avatar answered Oct 18 '22 18:10

Stefano Fedele