关于如何使用 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/