0

I am using math commons library but it turns out that when I want a function to return an Double, the intellij idea automatically corrects it to an object.

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


// TDistribution  --> It doesn't allow me to change to Double
fun calculo(a:Double): TDistribution {

    val distf = TDistribution(28.0,a)
    return distf
}

fun main(args: Array<String>){

    val ko = calculo(0.95)
    println(ko)
}

return it

org.apache.commons.math3.distribution.TDistribution@404b9385

1 Answer 1

1

Your function returns TDistribution. To return Double you need something like this:

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

fun main(args: Array<String>) {
    val ko = calculo(0.95)
    println(ko)
}
Sign up to request clarification or add additional context in comments.

2 Comments

hello, but for some reason it returns 0.0, do you know what I'm wrong about?
@royer It is another issue. I suggest you to create a new question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.