This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: T-Student question


On Tue, 29 Apr 2003, Asier wrote:

> I need to calculate one of the t-student parameters, but I don't know how to
> do it with the gsl library.
>
> If 't' is the tStudent probability, and t_X the probability with 'X' degrees
> of freedom P(t_7 < 2.11) I can get it with the gsl_rand_tdist_pdf(x, nu)
> function.
>
>     double d = gsl_rand_tdist_pdf(2.11, 7);
>
> ¿Ok?

No.  That gives you the *density* at 2.11.

> How can I calculate the t_(n-1;\alpha) probability

You need the CDF, the integral of the density.  The following code
might work (not tested, use at your own risk, etc.):

double
gsl_ran_tdist_cdf (const double x, const double nu)
{
  if (x == 0)
      return 0.5;
  else {
    double d = 0.5 * gsl_sf_beta_inc (0.5*nu, 0.5, nu/(nu + x*x));
    /* d as a function of x is symmetric about zero, but has a
       maximum there; adjust as follows(?): */
    return (x < 0)? d : 1 - d;
  }
}

This would give you the "probability" (let's not quibble) for the
one-sided t-test(?).  You'd then have to compare it to 1-alpha.

> Given I know the above 'd' and 'nu' numbers, how can I calculate the 'x'
> parameter of the function?

You're asking for the inverse CDF, I assume.  Are you sure you need
it?  In many applications you ultimately want to know whether you can
reject the null-hypothesis and at what p-value.  If you do your
calculcations from tables, then critical values of x are useful.  But
otherwise, what do you need them for?

- martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]