C# 的正态累积分布

时间:2021-04-19 14:10:48

标签: c# unity3d math cumulative-sum

我正在尝试将以下数学方程从表达式正态累积分布转换为 Unity 中的 C#。 NORMSDIST 是 Excel 中使用的表达式,我认为通过它可以在 C# 中完成。那么这个等式有简化的方法吗?

Cumulative

NORMSDIST (-0.48) = 0.31

1 个答案:

答案 0 :(得分:1)

感谢您的评论。我使用 using MathNet.Numerics; 实现了这一点。您可以通过安装 NuGet - https://github.com/GlitchEnzo/NuGetForUnity 来下载此 Unity 包。

因此,以下工作:

using System;
using System.Collections;
using System.Collections.Generic;
using MathNet.Numerics;
using UnityEngine;

public class CumulativeFunction : MonoBehaviour {
    void Start () {
        F (-0.48f);
    }

    static double F (double x) {
        MathNet.Numerics.Distributions.Normal result = new MathNet.Numerics.Distributions.Normal ();
        return result.CumulativeDistribution (x);

    }

}