Scientific Computing: Time Series Analysis with Python
• (This page is not constructed yet, however if you are interested in something send me an e-mail: gswelter at gmail dot com )

# Introduction

We make available some tools for statistical analysis of time series written in Python using the numpy and matplotlib libraries for scientific computing.

Consider $X$ to be a time series of $n$ data points. For Simplicity we assume $n$ to be a power of 2 in order to apply Fast Fourier Transform algorithm.

# Signals

## White Noise: whitenoise(n)

$\xi(t)$ is a i.i.d with uncorrelated Gaussian distribution
$\langle\xi(t) \rangle = 0$, $\langle\xi(t)\xi(s) \rangle = \sigma_\xi^2 \delta(t-s)$

Usage:

import pylab
n = 2**12
x = whitenoise(n)
plot(x)


## Wiener Process: wiener(n)

(1)
\begin{align} W(t) = \int_{-\infty}^{t}\xi(s)ds \end{align}

# Classical Analysis

### Powerspectrum: powerspectrum(x)

import numpy
def powerspectrum(x):
s = numpy.fft(x)
return numpy.real(s*numpy.conjugate(s))


### Autocorrelation Function: autocor(x)

$R(\tau) = \langle x(t)x(t+\tau)\rangle_t / \sigma_x^2$
Using the Wiener-Kintchine theorem we can obtain the autocorrelation via FFT

import numpy
def autocor(x):
s = numpy.fft.fft(x)
return numpy.real(numpy.fft.ifft(s*numpy.conjugate(s)))/numpy.var(x)

R = autocor(x)


### Integral Scale: integralscale(x)

$T = \int_0^{\infty} R(\tau) d \tau$

### Fourier Filter

Let

(2)
\begin{align} \hat{x} = \mathcal{F} \{x\} = \int_{\mathbb{R}} x(t)e^{-i\omega t} dt \end{align}

and

(3)
\begin{align} x = \mathcal{F}^{-1}\{\hat{x}\} = \frac{1}{2\pi}\int_{\mathbb{R}} \hat{x}(\omega)e^{i\omega t} d\omega \end{align}

be the pair of Fourier Transform of $x$.

#### High Pass: fourier_hp(x, fc)

A high-pass filter is defined as

(4)
\begin{align} x(t)_{<} = \frac{1}{2\pi} \int_{-\infty}^{\omega_c} \hat{x}(\omega)e^{i\omega t} d\omega \end{align}

where $\omega_c$ is angular-frequency cut.

#### Low Pass: fourier_lp(x, fc)

A low-pass filter is defined as

(5)
\begin{align} x(t)_{>} = \frac{1}{2\pi} \int_{\omega_c}^{\infty} \hat{x}(\omega)e^{i\omega t} d\omega \end{align}

### Structure Function: sf(x,q)

(6)
\begin{align} S(\tau,q) = \langle (x(t+\tau)-x(t))^q \rangle_t \end{align}

# Wavelet Transform

## Continuous Wavelet transform

(7)
\begin{align} T_\psi[x](a,b) = \int_{-\infty}^{\infty} x(t)\psi(\frac{t-b}{a}) dt \end{align}

## Discrete Wavelet Transform

(8)
\begin{align} \psi_{j,k}(t) = 2^{-j/2}\psi(2^i t -k) \end{align}
(9)
\begin{align} d_{j,k} = \int_{\mathbb{R}} x(t)\psi_{j,k}(t)dt \end{align}

# Multifractal Analysis

## Surrogates

• Random Fourier Phases surr_rfp(x)
• Iterative Amplitute Adjusted Fourier-Transform surr_iaaft(x)
• Multifractal surr_mf(x)

## Information Measures

### Information Entropy (Shannon's Entropy): entropy( x, nbins)

(10)
\begin{align} H= -\sum_ {i}p_i\log_2(p_i) \end{align}

### Mutual Information Content: mic(x,y, nbins)

page revision: 24, last edited: 13 Sep 2010 04:34