# [SciPy-User] why does scipy.stats.t.ppf return negative values?

Skipper Seabold jsseabold@gmail....
Mon Jun 4 20:42:40 CDT 2012

```On Mon, Jun 4, 2012 at 9:22 PM, pybokeh <pybokeh@gmail.com> wrote:
> I am reviewing sample problems in my statistics book from college.  When I
> look up the percentage point for t-distribution in the appendix of the book,
> it lists positive values.  When I use say for example:
> stats.t.ppf(0.025,15), it shows -2.131, whereas, my stat book shows 2.131.
> I tried other parameters and I get same values as what my stat book shows,
> but again the values it returns are negative.
>

You're in the left tail of the distribution. It's symmetric about
zero. 2.5 % of zero mean, unit variance numbers that follow Student's
t distribution are less than -2.131. 97.5% are less than 2.131.

nobs = 100000.
np.random.seed(12345)
rvs = stats.t(15).rvs(nobs)

print np.sum(rvs<stats.t.ppf(.025, 15))/nobs
#0.02548
print np.sum(rvs<stats.t.ppf(1-.025, 15))/nobs
#0.97441

stats.t.ppf(1 - .025, 15) == np.abs(stats.t.ppf(.025, 15))

Though you may notice things getting screwy close to 1 and 0,
depending on the implementation

alpha = 1e-9
stats.t.ppf(1 - alpha, 15) == np.abs(stats.t.ppf(alpha, 15))

alpha = np.linspace(0,1,100)
stats.t.ppf(alpha, 15)

Skipper
```

More information about the SciPy-User mailing list