Compare normal and log-normal random variables

Compare normal and log-normal random variables#

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from scipy.stats import norm, lognorm


# picking 150 of from a normal distrubution
# with mean 0 and standard deviation 1
samp1 = norm.rvs(loc=0,scale=1,size=150)
numargs = lognorm.numargs
[ s ] = [0.9,] * numargs
rv = lognorm(s)
samp2 = rv.rvs(size=150)

plt.figure()
plt.plot(samp1,'o')
plt.title('Normally distributed random variable')

plt.figure()
plt.plot(samp2,'gs')
plt.title('Log-normally distributed random variable')


plt.figure()
plt.plot(np.log10(samp2),'go')
plt.title('Log of log-ormally distributed random variable')
# ylim((-2,6))


plt.figure();
plt.hist(np.log(samp2));
plt.hist(samp2,alpha=.63);
../_images/459652f1ec85601f9f11603bdcf1aaf39a42643b511d7c950f0ed279c5c82556.png ../_images/797c16bb08be559520e79ea388d675b5b4bc9b2a8529c10eb16559f439ddb96a.png ../_images/43ace6e7917eaee35ce95646cf48c49d1a10d673f76909125dccc4e375373a51.png ../_images/4ee28269274903c2b9859145f5096d51c71e387069f4ad233d1a27179924b6c9.png