This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statsmodels.sandbox.distributions.extras as extras | |
import scipy.interpolate as interpolate | |
import numpy as np | |
def generate_normal_four_moments(mu, sigma, skew, kurt, size=1000, sd_wide = 10): | |
f = extras.pdf_mvsk([mu, sigma, skew, kurt]) | |
x = np.linspace(mu - sd_wide * sigma, mu + sd_wide * sigma, num=500) | |
y = [f(i) for i in x] | |
yy = np.cumsum(y) / np.sum(y) | |
inv_cdf = interpolate.interp1d(yy, x, fill_value="extrapolate") |