逆正态累积分布函数转换

时间:2022-02-28 00:32:40

we used the Extreme Numerics library from Extreme Optimization (http://www.extremeoptimization.com) for our calculation kernel.

我们使用Extreme Optimization(http://www.extremeoptimization.com)的Extreme Numerics库作为我们的计算内核。

// portfolio risk is inverse normal cumulative distribution function
double risk = NormalDistribution.InverseDistributionFunction(
  _riskProbabilityLevel, 
  mean, 
  stdev);

The problem is now we are moving from C# to Java and I don't really know all that much about Java but have been tasked with re-writing this particular function.

问题是现在我们正在从C#转向Java,我对Java并不是很了解,但我们的任务是重写这个特定的功能。

I have values to test against:

我有值得测试的价值:

RiskProbabilityLevel = 0.02
Mean                 = 0.06618
Standard Dev         = 0.057196166520267355

Risk                 = 0.051286461995869864

but in looking thru the various functions in math3.distribution.NormalDistribution libraries I can't find what might be equivalent.

但是在查看math3.distribution.NormalDistribution库中的各种函数时,我找不到可能相同的东西。

Any direction or help would be appreciated. thanks.

任何方向或帮助将不胜感激。谢谢。

1 个解决方案

#1


6  

I think you can use this library. It's called apache commons.math3. It's very popular. From the docs supplied by http://www.extremeoptimization.com I think you can use the following code:

我想你可以使用这个库。它叫做apache commons.math3。它很受欢迎。从http://www.extremeoptimization.com提供的文档中,我认为您可以使用以下代码:

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

public class TestProbabilites {

    public static void main(String[] args) {
        double riskProbabilityLevel = 0.02D;
        double mean = 0.06618D;
        double standardDev = 0.057196166520267355D;
        double expectedRisk = 0.051286461995869864D;

        NormalDistribution distribution = new NormalDistribution(mean, standardDev);
        double outcomeRisk = distribution.inverseCumulativeProbability(riskProbabilityLevel);
    }
}

But you have to remember to add the apache.commons.math3 library added to your project using Maven or Gradle or some other dependencies manager.

但是你必须记住使用Maven或Gradle或其他一些依赖项管理器添加添加到项目中的apache.commons.math3库。

Hopes this helps.

希望这会有所帮助。

#1


6  

I think you can use this library. It's called apache commons.math3. It's very popular. From the docs supplied by http://www.extremeoptimization.com I think you can use the following code:

我想你可以使用这个库。它叫做apache commons.math3。它很受欢迎。从http://www.extremeoptimization.com提供的文档中,我认为您可以使用以下代码:

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

public class TestProbabilites {

    public static void main(String[] args) {
        double riskProbabilityLevel = 0.02D;
        double mean = 0.06618D;
        double standardDev = 0.057196166520267355D;
        double expectedRisk = 0.051286461995869864D;

        NormalDistribution distribution = new NormalDistribution(mean, standardDev);
        double outcomeRisk = distribution.inverseCumulativeProbability(riskProbabilityLevel);
    }
}

But you have to remember to add the apache.commons.math3 library added to your project using Maven or Gradle or some other dependencies manager.

但是你必须记住使用Maven或Gradle或其他一些依赖项管理器添加添加到项目中的apache.commons.math3库。

Hopes this helps.

希望这会有所帮助。