Search code examples
javarapache-commons-math

Student t-distribution different values


When I run student t-distribution in R, I get following:

> pt(1.849, 2, lower.tail=FALSE)
[1] 0.1028493

When I run same with Apache Commons Math library, I get following:

  TDistribution td = new TDistribution(2);
  System.out.println(td.density(1.849));
  O/P: 0.07927663297535456

Values are completely different. Is this expected behavior (or) Am i missing something?

EDIT: When I used cumulativeProbability I got following output, which is also far different from R value.

0.8954597327733625

Solution

  • The output from Apache Common Math seems to be the value of the density function.

    > dt(1.849, 2)
    [1] 0.07927663