kotlinapache-commons-math

How can I get the value of a T-student distribution?


I have been reviewing the documentation of apache commons math and I find that it also calculates distributions, but I can not understand how it works.

I have two values

My problem is that it does not yield the value I need, The objective is:

result = 1.771

import org.apache.commons.math3.distribution.TDistribution


fun calculo(a:Double, b:Double): Double {
    val distf = TDistribution(a,b)
    return distf.getNumericalMean()
}

fun main(args: Array<String>) {
    val ko = calculo(13,0.95)
    println(ko)
}
```

Solution

  • You can use the following:

    new org.apache.commons.math3.distribution.TDistribution(deg_freedom).
        inverseCumulativeProbability(probability)
    

    Where deg_freedom=13, and probability=0.95.