... from functools import partial
import numpy
from pylab import figure, show
from pacal import *
|
||
.
|
||
Using compiled interpolation routine
... from pacal.distr import demo_distr
|
||
.
|
||
Example 5.1.3
... d = NormalDistr() + NormalDistr() * NormalDistr()
demo_distr(d)
|
||
.
|
||
============= summary ============= N(0.0,1.0)+N(0.0,1.0)*N(0.0,1.0) mean = 2.22044604925e-16 std = 1.41421356237 var = 2.0 median = 0.0 medianad = 0.864135618196 iqrange(0.025) = 5.63838771975 range = (-inf, inf) ci(0.05) = (-2.8191938598737281, 2.8191938598740514) int_err = -8.881784197e-16
... |
||
.
|
||
Example 5.5
... d = ExponentialDistr() / (ExponentialDistr() + ExponentialDistr())
figure()
demo_distr(d, xmax=20, ymax=1.5)
|
||
.
|
||
============= summary ============= ExpD(1)/(ExpD(1)+ExpD(1)) mean = 1.0 std = inf var = inf median = 0.414213562373 medianad = 0.318580491791 iqrange(0.025) = 5.31181595325 range = (0.0, inf) ci(0.05) = (0.012739367083666622, 5.3245553203367351) int_err = -2.22044604925e-16
... |
||
.
|
||
Exercise 5.5 part a
... figure()
demo_distr(NormalDistr() / sqrt((NormalDistr()**2 + NormalDistr()**2) / 2), xmin=-3, xmax=3)
|
||
.
|
||
============= summary ============= N(0.0,1.0)/exp(0.5*log(0.5*(sqr(N(0.0,1.0))+sqr(N(0.0,1.0))))) mean = 2.22044604925e-16 std = inf var = inf median = 0.0 medianad = 0.816496580928 iqrange(0.025) = 8.6053054595 range = (-inf, inf) ci(0.05) = (-4.3026527297494699, 4.3026527297494095) int_err = -6.66133814775e-16
part b
... figure()
demo_distr(2 * NormalDistr()**2 / (NormalDistr()**2 + NormalDistr()**2), xmax=20, ymax=2)
|
||
.
|
||
============= summary ============= (2*sqr(N(0.0,1.0)))/(sqr(N(0.0,1.0))+sqr(N(0.0,1.0))) mean = nan std = nan var = nan median = 0.666666664933 medianad = 0.633525148605 iqrange(0.025) = 38.5050763413 range = (0.0, inf) ci(0.05) = (0.0012507817364725586, 38.506327122991905) int_err = -1.26784627241e-09
part c
... figure()
demo_distr(3 * NormalDistr()**2 / (NormalDistr()**2 + NormalDistr()**2 + NormalDistr()**2), xmax=20, ymax=2)
|
||
.
|
||
============= summary ============= (3*sqr(N(0.0,1.0)))/(sqr(N(0.0,1.0))+sqr(N(0.0,1.0))+sqr(N(0.0,1.0))) mean = 3.00000290384 std = inf var = inf median = 0.585060274052 medianad = 0.550673034457 iqrange(0.025) = 17.4422851227 range = (0.0, inf) ci(0.05) = (0.0011571891323882905, 17.44344231184073) int_err = -1.84488713195e-09
part d
... figure()
demo_distr((NormalDistr()**2 + NormalDistr()**2) / (NormalDistr()**2 + NormalDistr()**2), xmax=20)
|
||
.
|
||
============= summary ============= (sqr(N(0.0,1.0))+sqr(N(0.0,1.0)))/(sqr(N(0.0,1.0))+sqr(N(0.0,1.0))) mean = nan std = nan var = nan median = 1.0 medianad = 0.828427124746 iqrange(0.025) = 38.9743589744 range = (0.0, inf) ci(0.05) = (0.025641025641025626, 38.999999999998309) int_err = -1.11022302463e-15
... |
||
.
|
||
Exercise 5.6
... d = sqrt(UniformDistr(0,1)**2 + UniformDistr(0,1)**2)
# a bug in Springer??
def theor_ampl_uni(x):
return (x<1)*numpy.pi/2*x + (x>=1)*(2*numpy.arcsin(1.0/x) - 0*numpy.pi/2)
figure()
#demo_distr(d, theoretical = theor_ampl_uni, histogram=True)
demo_distr(d)
|
||
.
|
||
============= summary ============= exp(0.5*log(sqr(U(0,1))+sqr(U(0,1)))) mean = 0.765195581011 std = 0.284854655401 var = 0.0811421747037 median = 0.797884560803 medianad = 0.199471140201 iqrange(0.025) = 1.08115660638 range = (0.0, 1.4142135623730949) ci(0.05) = (0.17841241161525598, 1.259569017999167) int_err = 1.35453914085e-07
... show()
|
||
.
|
||