Simple addition to random module - Student's t
Mark Dickinson
dickinsm at gmail.com
Wed Sep 2 20:37:33 CEST 2009
On Sep 2, 6:15 pm, Thomas Philips <tkp... at gmail.com> wrote:
> I mis-spoke - the variance is infinite when df=2 (the variance is df/
> (df-2),
Yes: the variance is infinite both for df=2 and df=1, and Student's t
with df=1 doesn't even have an expectation. I don't see why this
would stop you from generating meaningful samples, though.
> and you get the Cauchy when df=2.
Are you sure about this? All my statistics books are currently hiding
in my mother-in-law's attic, several hundred miles away, but wikipedia
and mathworld seem to say that df=1 gives you the Cauchy distribution.
> I made the mistake because the denominator is equivalent to the
> square root of the sample variance of df normal observations,
As I'm reading it, the denominator is the square root of the sample
variance of *df+1* independent standard normal observations. I agree
that the wikipedia description is a bit confusing.
It seems that there are uses for Student's t distribution with
non-integral degrees of freedom. The Boost library, and the R
programming language both allow non-integral degrees of freedom.
So (as Robert Kern already suggested), you could drop the test
for integrality of df. In fact, you could just drop the tests
on df entirely: df <= 0.0 will be picked up in the gammavariate
call.
--
Mark
More information about the Python-list
mailing list