You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2022/11/12 16:55:00 UTC

[jira] [Resolved] (STATISTICS-25) T Distribution Inverse Cumulative Probability Function gives the Wrong Answer

     [ https://issues.apache.org/jira/browse/STATISTICS-25?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Herbert resolved STATISTICS-25.
------------------------------------
    Fix Version/s: 1.0
         Assignee: Alex Herbert
       Resolution: Fixed

Removed early switch of CDF to the normal distribution in commit:

3ee52f7ca0883495e0df1ca2a914ad24b5ba968a

The normal distribution is now used for both the PDF and CDF at approximately 3.6e16.

> T Distribution Inverse Cumulative Probability Function gives the Wrong Answer
> -----------------------------------------------------------------------------
>
>                 Key: STATISTICS-25
>                 URL: https://issues.apache.org/jira/browse/STATISTICS-25
>             Project: Commons Statistics
>          Issue Type: Bug
>          Components: distribution
>            Reporter: Andreas Stefik
>            Assignee: Alex Herbert
>            Priority: Major
>             Fix For: 1.0
>
>
> Hi There,
> Given code like this:
>  
> import org.apache.commons.math3.analysis.UnivariateFunction;
> import org.apache.commons.math3.analysis.solvers.BrentSolver;
> import org.apache.commons.math3.distribution.TDistribution;
> public class Main {
>  public static void main(String[] args) {
>  double df = 1E38;
>  double t = 0.975;
>  TDistribution dist = new TDistribution(df);
>  
>  double prob = dist.inverseCumulativeProbability(1.0 - t);
>  
>  System.out.println("Prob: " + prob);
>  }
> }
>  
> It is possible I am misunderstanding, but that seems equivalent to:
>  
> scipy.stats.t.cdf(1.0 - 0.975, 1e38)
>  
> In Python. They give different answers. Python gives 0.509972518193, which seems correct, whereas Apache Commons gives  Prob: -6.462184036284304E-10. That's a huge difference.
> My hunch is that as you get closer to infinity it begins to fail, but I haven't checked carefully. For calls with much smaller degrees of freedom, you get answers that are basically the same as Python or online calculators.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)