c# - 使用 Math.NET 计算临界值 T-Score
问题描述
关于如何使用 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 是否返回双尾值,如果不只是调整概率
您还可以在此处与临界值进行比较
更新
下面的 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# - 如何将参数传递给基本映射配置文件的构造函数?
- java - 在二维数组中发现相同的模式
- amazon-web-services - 为什么云端无法映射 EC2 DNS
- julia - 如何找到代码中最耗时的部分?
- php - 在 Woocommerce Admin Orders 列表中搜索自定义列的值
- asp.net - 通过 TBA(基于令牌的身份验证)从 ASP.NET 与 Netsuite 集成
- python - 如何解析相对于任何目录的相对路径
- javascript - 我不能引用 const 因为“未定义”但它是
- laravel - 在 Laravel 验证请求中,如何在更新时处理不同列的唯一性
- python - 计算两个 txt.files 之间的相似度