ebrahimpichka / LSM-denoise

Denoising time series using Least Squares Method in python using NumPy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LSM-denoise

Denoising time series e.g. historical price data using Least Squares Method in python using NumPy.

How to use:

The denoise function in lsm-denoise.py simply could be used by passing a 1-dim numpy array of time series data to the function.

example:

denoised_prices = denoise(
    price_vec,
    LAMBDA=100,
    plot=True
    )

Intuition:

suppose y is the time series vector, x is the denoised vector and v is an unknown noise vector

eq1

to find x we need to solve the following minimization problem using least squares method:

eq2

this problem minimizes the noise factor v with the penalty of the difference between two consequetive x values become minimized.

the penalty term could be written as:

eq3

where D is an (n-1)x(n) matrix like:

eq4

and finally the main minimization problem could be re-written as:

eq5

Results:

an example of denoised time series by different LAMBDA valuse plotted below:

plot

About

Denoising time series using Least Squares Method in python using NumPy.


Languages

Language:Jupyter Notebook 99.3%Language:Python 0.7%