In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import ebm_analytical as ebm
from scipy import stats, integrate

In [2]:
#  Two PDFs for delta
# First is Lognormal distribution with shape parameter 1.0,
#  scale parameter 1.0 and location parameter 0.
#    (mode at delta = 0.37, median at delta = 1.)
# Second is Lognormal with shape parameter shape parameter 2.0, 
#  scale parameter e and location parameter 0.
darray = np.linspace(0., 10., 200)
plt.plot(darray, ebm.h_delta_0(darray), 'b-', label='PDF0')
plt.plot([0.37, 0.37], [0, 1], 'b--')
plt.plot(darray, ebm.h_delta_1(darray), 'g-', label='PDF1, PDF2')
plt.plot(np.exp(-3)*np.ones(2), [0, 1], 'g--')
plt.xlabel(r'$\delta$', fontsize=16)
plt.legend()


Out[2]:
<matplotlib.legend.Legend at 0x1069d3d10>

In [3]:
#  The PDF for q
#  Lognormal with shape parameter 0.5, scale parameter 1.0 and location parameter 0.
#  (mode at q=0.78, median at q=1)
qarray = np.linspace(0., 4.)
plt.plot(qarray, ebm.h_q_0(qarray), 'b-', label='PDF0,PDF1, PDF2')
plt.plot([0.78, 0.78], [0, 1], 'b--')
#plt.plot(qarray, ebm.h_q_1(qarray), 'g-', label='PDF1, PDF2')
plt.xlabel(r'$q$', fontsize=16)
plt.legend()


Out[3]:
<matplotlib.legend.Legend at 0x110c16310>

In [4]:
#  The two PDFs for alpha
alpha = np.linspace(0., 1.)
plt.plot(alpha, ebm.h_alpha_0(alpha), label='PDF0, PDF1')
plt.plot(alpha, ebm.h_alpha_2(alpha), 'm-', label='PDF2')
plt.plot([0.5, 0.5], [0, 1.5], 'm--')
plt.xlabel(r'$\alpha$', fontsize=16)
plt.legend()


Out[4]:
<matplotlib.legend.Legend at 0x1134cecd0>

Verify that all distributions integrate out to 1


In [5]:
for h_delta in [ebm.h_delta_0, ebm.h_delta_1, ebm.h_delta_2]:
    print integrate.quad(lambda delta: h_delta(delta), 0, np.infty)


(0.9999999999942906, 1.0057699931758784e-08)
(1.0000000001307854, 7.393280210266084e-09)
(1.0000000001307854, 7.393280210266084e-09)

In [6]:
for h_q in [ebm.h_q_0, ebm.h_q_1, ebm.h_q_2]:
    print integrate.quad(lambda q: h_q(q), 0, np.infty)


(0.99999999999995, 9.1235764587357e-09)
(0.99999999999995, 9.1235764587357e-09)
(0.99999999999995, 9.1235764587357e-09)

In [7]:
for h_alpha in [ebm.h_alpha_0, ebm.h_alpha_1, ebm.h_alpha_2]:
    print integrate.quad(lambda alpha: h_alpha(alpha), 0, 1)


(1.0, 1.1102230246251565e-14)
(1.0, 1.1102230246251565e-14)
(1.0, 1.1102230246251565e-14)

There was a problem with the previous h_q_1 function ... did not integrate to 1. But I'm not using it anymore.


In [ ]: