Search code examples
javaapache-commons

how to use org.apache.commons.math3.distribution


I have the following code, but when I run, I don't even get a number and I'm not sure why. do I have to use a different constructor? I tried but one of the arguments in a different constructor is a random number generator, and won't let me put in any sort of number for it. And please guys, be nice, I know I Don't know very much about distributions or java, I'm just learning.

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

public class Math33 {
    public static void main(String[] args){
        TDistribution TScore = new TDistribution(1, 5);
        System.out.println(TScore);
    }
}

I get this as output:

org.apache.commons.math3.distribution.TDistribution@18f55759

Solution

  • Because you put an object of TDistribution into method System.out.println() so it's print you a string presentation of the object. What you need is to call so of TDistribution's methods inside System.out.println(). For example:

    System.out.println("" + TScore.getNumericalVariance());
    

    or any other which is available for TDistribution