In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')


/usr/local/miniconda/lib/python2.7/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

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 [ ]: