In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
In [4]:
import pandas as pd
In [5]:
import numpy as np
import statsmodels as sm
from scipy import stats
In [6]:
rng = np.random.RandomState(0)
In [7]:
rands = rng.normal(0., 1.0, size=10000)
ecdf = sm.distributions.ECDF(rands)
samples = sm.distributions.monotone_fn_inverter(ecdf, np.arange(-10., 10., 0.1))
In [11]:
gridpts = np.arange(-5., 5., 0.01)
fig, ax = plt.subplots()
ax.plot(gridpts, stats.norm.pdf(gridpts, 0., 1.0), lw=4, color='k')
_ = ax.hist(rands, bins=np.arange(-5., 5., 0.1), histtype='step', lw=2, normed=1, color='k')
_ = ax.hist(samples(np.random.uniform(size=10000)), bins=np.arange(-5., 5., 0.1),
histtype='step', lw=2, normed=1, color='r')
_ = ax.hist(samples(np.random.uniform(size=10000)), bins=np.arange(-5., 5., 0.1),
histtype='step', lw=2, normed=1, color='g')
In [ ]:
In [ ]: