How to solve for an Z-Score of a T-Distribution?
David's method is the route I would go if I didn't want to use Quantile
for some reason.
Quantile[StudentTDistribution[49], .95]
==> 1.67655
If you really want to use PDF's to demonstrate this you can still use FindRoot
by first setting the integration up so that it only accepts numeric input.
f[y_?NumericQ] := NIntegrate[PDF[StudentTDistribution[49], x], {x, -Infinity, y}]
FindRoot[f[y] == 0.95, {y, 1}]
==> {y -> 1.67655}
Have you tried FindRoot
? It's a numerical function looking for a root given some starting location. In addition to that, you can get around integrating by using CDF
instead of PDF
in the first place:
FindRoot[CDF[StudentTDistribution[49], y] == 0.95, {y, 1}]
{y -> 1.67655}
If you're interested, the reason why your first approach doesn't work: NIntegrate
cannot use placeholders, it has to evaluate to a number in all cases. What you're trying to do is equivalent to NIntegrate[x*y, {x,0,1}]
, and the program complains that it does not know the full integrand since y is undefined, therefore it cannot be evaluated. The fact that you've wrapped a Solve
, which inserts the missing variable (x
in your case) after NIntegrate
has been evaluated, does not have any impact on that.