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/b54594ea197d06facd6f16cda5301d0cf5f48e52589f4346a00c3828d51d258b.png ../_images/d73f734500a80fab0b8b4e14bd116e27154ef8320dd07f922dda3fa532e21468.png ../_images/3d2f47ead712818115bb2e1e0635c540ee6ffacda01fee1789ba7f3ec141759a.png ../_images/20b641cc5f3d9caad786585e16fd58cc1b350509373cd0d31fa2ec4ecdea2f24.png