【问题标题】:T-Test and PValue- Math.Net Numerics classT 检验和 P 值 - Math.Net 数值类
【发布时间】:2017-10-11 21:29:27
【问题描述】:

有没有一种方法可以从 StudentT 类中获取 ttest-value 和 P-Value。我正在尝试从这个库中计算这些值:https://numerics.mathdotnet.com/api/MathNet.Numerics.Distributions/StudentT.htm

excel的等效函数是T-Test。但是我在 math.net numerics excel 函数中没有这种方法。下面的链接显示了所有的 excel 方法: https://numerics.mathdotnet.com/api/MathNet.Numerics/ExcelFunctions.htm

从上述库中完成此操作的任何指针都会有很大帮助。

谢谢...

【问题讨论】:

    标签: c# statistics p-value t-test


    【解决方案1】:

    我不知道如何在 Math.Net 中执行此操作,但我知道如何在 Meta.Numerics 中执行此操作:

            Sample sample1 = new Sample(1.0, 2.0, 3.0, 4.0);
            Sample sample2 = new Sample(3.0, 4.0, 5.0, 6.0);
            TestResult tTest = Sample.StudentTTest(sample1, sample2);
            Console.WriteLine("t = {0}", tTest.Statistic);
            Console.WriteLine("P = {0} ({1})", tTest.Probability, tTest.Type);
    

    如果您对更改数学库不感兴趣,我理解,但由于您的问题已经过了一段时间没有答案,我想我会插话。

    【讨论】:

    • 你将如何为整个人群而不只是一个样本做同样的代码?
    • @user3610374 如果两个样本都包含完整的总体,则无需进行测试。 t 检验的原假设是两个总体相同。如果您有两个总体,那么它们与 P = 0 或 P = 1 相同。如果只有一个样本是全部样本且均值为 m,则可以使用 s.StudentTTest(m) 将其与子样本 s 进行比较,计算 $t = (\mu - m) / (\sigma / \sqrt{n })$。这通常称为单样本 t 检验 (en.wikipedia.org/wiki/Student%27s_t-test#One-sample_t-test)。
    【解决方案2】:

    以下是如何使用 MathNet.Numerics 库集执行左尾 t 检验。

    假设您有一些数据在一个数组中,并且您已经计算了所有需要的初步统计数据,如下所示。

        int n = 5;    //size of sample
        double hypotheziedMean = 50.0;   
        double sampleMean = 50.03;
        double sampleSD = 1.5;    //sample standard deviation (n-1)
    
        double stdErr = sampleSD / Math.Sqrt(n);    //standard error of the mean
        double t = (sampleMean - hypotheziedMean) / stdErr;   //convert to a standard mean of 0 and SD of 1
    
        StudentT st = new StudentT(0, 1, n-1); //create a standard StudentT object with n-1 DOF
    
        double pVal = st.CumulativeDistribution(t);  //left tail pval
    

    【讨论】:

      猜你喜欢
      • 2021-09-07
      • 2019-09-09
      • 2011-02-21
      • 2017-07-11
      • 2021-01-05
      • 1970-01-01
      • 2018-11-19
      • 2022-01-07
      • 1970-01-01
      相关资源
      最近更新 更多