from scipy import stats import pandas as pd import numpy as np import pylab import matplotlib.pyplot as plt
%matplotlib inline
x = stats.loggamma.rvs(5, size=500) + 5
pd.Series(x).hist() plt.show() stats.probplot(x, dist="norm", plot=pylab) pylab.show()
pd.Series(np.log(x)).hist() plt.show() stats.probplot(np.log(x), dist="norm", plot=pylab) pylab.show()
pd.Series(np.sqrt(x)).hist() plt.show() stats.probplot(np.sqrt(x), dist="norm", plot=pylab) pylab.show()
x_bc, lmda = stats.boxcox(x) pd.Series(x_bc).hist() plt.show() stats.probplot(x_bc, dist="norm", plot=pylab) pylab.show() print "lambda parameter for Box-Cox Transformation is {}".format(lmda)