javascriptjstat

T-distribution with confidence level in Javascript


What's the jStat function to calculate the t-distribution with a predefined confidence level?

jStat.???(1, 0.99) # == 63.67
jStat.???(10, 0.99) # == 3.17
jStat.???(1, 0.95) # == 12.69

http://uregina.ca/~gingrich/tt.pdf


Solution

  • You can use jStat.studentt.inv( p, dof ) like so:

    function tdist(df, conf_lvl) {
      return jStat.studentt.inv((1 - (1 - conf_lvl) / 2), df)
    }
    

    .inv(p, dof) returns a desired value for a given p = (1 - alpha) where alpha value is the amount of area in one trail, wheras the confidence level is (1 - 2 * alpha) [it excludes area in both trails]