[SciPy-User] scipy.stats.uniform gives strange behavior (error?)
Pauli Virtanen
pav@iki...
Tue Aug 3 15:14:54 CDT 2010
Tue, 03 Aug 2010 21:35:42 +0200, nicky van foreest wrote:
> It seems that the sum over the density of the uniform distribution does
> not always produces 1 (after proper division). Here is the code:
[clip]
> rv = uniform(loc=1., scale = 0.1)
> f = rv.pdf(arange(delta, len(grid)*delta,delta))*delta # 1 print
It's a continuous distribution, and the *integral* over the PDF should
give 1, and it indeed does:
>>> from scipy.integrate import quad
>>> quad(rv.pdf, 0, 2)
(0.99999999999999989, 1.1102230246251563e-15)
If you approximate the integral with a sum, as you did above, be prepared
to get finite integration error.
--
Pauli Virtanen
More information about the SciPy-User
mailing list