'Create surrogate data in python using fourier transform?
I want to create 10,000 sample (random phase but same power spectra) of my original time series using fourier transform. The method I want to opt is given in figure. The actual time series data can be found here Data link
Method details figure_please see this**
so far I understood that I first need to used scipy.fft.fft on my original data..
import scipy.fft
import pandas as pd
import numpy as np
######
var=np.loadtxt('DataQ.txt');
data=pd.DataFrame({'var1':var[:,0],'var2':var[:,1]});
##-first part of the method---------
def DFT(x):
"""
Function to calculate the
discrete Fourier Transform
of a 1D real-valued signal x
"""
N = len(x);
n = np.arange(N);
k = n.reshape((N, 1));
e = np.exp(2j * np.pi * k * n / N);
X = np.dot(e, x);
return X
X=DFT(data['var1'].values);
The second step I need help.
I am looking forward to your reply on the method of generating surrogate data using the method specified in figure.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|