eSurfsnake
eSurfsnake

Reputation: 689

scipy.stats doesn't work right with frozen RV

I am using scipy.stats. Most distributions allow you to "freeze" an RV like so:

rv=scipy.stats.norm(mean, sigma)

then, later, you can ask for (say):

 rv.pdf(0)

or

rv.mean()

and get a value that makes sense (in this case 0.5 and 0, respectively).

The t-dist offers a 'loc' and 'scale' param, but they don't seem to freeze. In other words, by testing, you can set

rv = scipy.stats.t(df=100000, loc=5, scale=2), 

and a graph looks like a normal dist (given the huge DOF) centered at 5 w/ stdev=2.

However, when you as for mean() or stdev() , it gives you (consistent with the documentation) the results for a normalized t-dist, with loc = 0 and stdev = 1.

Any ideas? This seems a break with the rest of scipy.stats.

Upvotes: 0

Views: 323

Answers (1)

Koralp Catalsakal
Koralp Catalsakal

Reputation: 1124

Correct me if I understood the problem wrong, but when I run this code

import scipy
import scipy.stats
from scipy.stats import t

rv_t = t(df=100000, loc=12, scale=2)
print(rv_t.mean())

I see the mean of the t-dist as 12(Namely the equivalent of loc value)

Upvotes: 2

Related Questions