Marcenko-Pastur Theorem - Generate Probability Density Function

## mpPDF.py

import numpy as np, pandas as pd

import matplotlib.pyplot as plt
# -Generate Probability Density Function as per Marcenko Pastur Theorem, for random process with zero mean, and specified variance
def mpPDF(var,q,pts):
# Var - Variance of the underlying process. Different variance will generate different PDF
#q = T/N T is #observations, N is #Independent Variables
#pts - How granularly you want to plot eigen values from Min Eigen Value to Max Eigen Value
eMax = var*(1+((1./q)**.5)) # Max Eigen Value
eMin = var*(1-((1./q)**.5)) # Min Eigen Value
eVal = np.linspace(eMin,eMax,pts) # Divide space b/w Min & Max Eigen into equally spaced intervals
pdf = (q/(2*np.pi*eVal*var))*(((eMax-eVal)*(eVal-eMin))**.5) # PDF as per Theorem
pdf = pd.Series(pdf,index=eVal) # Use Pandas to store result as series, index with Eigen value
return pdf # Return the Probability Density Function

Comments

Popular posts from this blog

1.2 Structured Data: Information Driven Bars

2.2 Labeling: Triple barrier method

Denoise a Covariance Matrix using Constant Residual Eigen Value Method