c# - 使用 Math.NET 计算临界值 T-Score

标签 c# statistics distribution math.net t-test

关于如何使用 Math.NET 计算 t 分布中的临界值,有什么想法吗?

更具体地说,我正在寻找如何使用 Math.NET 计算以下 Excel 函数。

=T.INV.2T(0.05, 8)

最佳答案

怎么样

var x = MathNet.Numerics.Distributions.StudentT.InvCDF(location:0.0, scale:1.0, freedom: (double)8, p: 0.05);

检查T.INV.2T是否返回双尾值,如果没有就调整概率

您还可以与临界值 here 进行比较

更新

下面的 C# 代码(.NET Core 3.1、Math.NET v4.9、Win10 x64)

using System;
using MathNet.Numerics.Distributions;

namespace Tinv
{
    class Program
    {
        public static double T_INV_2T(double p, double nu)
        {
            return StudentT.InvCDF(location:0.0, scale:1.0, freedom: nu, p: 1.0 - p/2.0);
            // same as             return Math.Abs(StudentT.InvCDF(location:0.0, scale:1.0, freedom: nu, p: p/2.0));

        }

        static void Main(string[] args)
        {
            var x = T_INV_2T(0.05, (double)8);
            Console.WriteLine($"Output = {x}");
        }
    }
}

产生的输出

2.306004135204172

其中 Excel 生成的值 =T.INV.2T(0.05, 8) 等于 2.306004,在 NIST 表中链接值列为 2.306

看起来很一致

关于c# - 使用 Math.NET 计算临界值 T-Score,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59473824/

相关文章:

python - 逻辑回归 - 计算每个属性对最终概率的贡献程度

algorithm - 在均匀大小的桶之间随机分布,不重复

c# - 通过智能卡验证 Windows 登录

r - 在 R 中绘制逻辑回归曲线

c# - 从泛型类派生的类中缺少构造函数

python - 属性错误: 'NoneType' object has no attribute 'setCallSite'

r - 使用 fitdistplus 中的 fitdist 和二项式分布

python - 如何提示 Sympy 逆高斯方程的积分

c# - 广播是否比特定端口的随机 SYN/ACK 扫描更快?

c# - 如何将图像设置为图表轴或沿图表轴设置?