#!/usr/bin/env python
# (C) 2000 Huaiyu Zhu <hzhu@users.sourceforge.net>. Licence: GPL
# $Id: test_probs.py,v 1.7 2000/08/06 07:21:17 hzhu Exp $
"""
Statistical distributions
"""
from MatPy.Stats.utils import histplot
if __name__ == "__main__": waittime = None
else: waittime = 1
i = 0
def test(g, dist, x, __name__):
"For dist: generate rand, draw pdf, cdf and cdfc on points x"
global i
print dist.__doc__
print dist.rand((2,5))
g.title("The %s distribution" % dist.__class__.__name__)
n = 400
y = dist.rand((n,1))
histplot(y, x=30, waittime=1, g=g, scaled=1)
g.holdon
curves = [dist.pdf(x), dist.cdf(x), dist.cdfc(x)]
g.plot(curves, xs=[x]*3, names=["pdf", "cdf", "cdfc"])
g.hardcopy("probs_%s.ps" %i)
i = i + 1
g.holdoff
wait(waittime)
#------------------------------------------------------------------
from MatPy.gplot import Gplot,wait
g = Gplot()
from MatPy.Stats.distribs import binomial,negbinomial,poisson
from MatPy.Stats.distribs import beta,gamma,normal,chi2,t,F
from MatPy.Matrix import r_range
x = r_range(100)/10.
#------------------------------------------------------------------
print "-"*30, "Testing distributions in [-Inf, Inf]"
for dist in [normal(), t(2)]:
test(g, dist, x-5, __name__)
print "-"*30, "Testing distributions in [0, Inf]"
for dist in [gamma(2,1), chi2(4), F(5,9)]:
test(g, dist, x+1e-100, __name__)
"""
binomial,
negbinomial,
poisson,
beta,
gamma,
normal,
chi2,
t,
F,
"""
|