【问题标题】:Using scipy stats, how can I implement a statistical test in my if else statement?使用 scipy stats,如何在 if else 语句中实现统计测试?
【发布时间】:2013-11-21 15:35:56
【问题描述】:

如何在 python 的 if else 语句中实现统计测试?我正在使用 scipy 统计信息。我想要实现的代码的一小部分是:

def choose():

        global sample

        if q1.get() == 1 and q2.get() == 1 and q3.get() == 2 and q4.get() == 2 and  q5.get() == 1 and q6.get() == 2 and q7.get() == 2 and q8.get() == 2 and q9.get() == 2 :
            tkMessageBox.showinfo( 'decision', 'You should use the t-test!')
            stats.ttest_1samp()
            #will do t-test here
            print sample
            # now sample list contains the data for doing t-test,
            #you just need to call t-test to get the results and show it on message box

【问题讨论】:

    标签: python if-statement statistics scipy


    【解决方案1】:

    不清楚您要测试的内容。 stats.ttest_1samp() 有两个参数,一个是观察样本(在你的情况下sample,应该是浮点/整数值列表),另一个是总体平均值。 T 检验测试您的样本均值是否与总体均值显着不同(您还应该提供)。

    T 检验返回 2 个值,第一个是所谓的 T 分数,第二个是与该 t 分数相关的概率(小概率表明您的 sample 平均值和总体平均值之间的差异非常显着)。这部分很简单,只需获取值,将它们转换为str 并将它们显示在消息框中您想要的位置。比如:

    MessageBox.showinfo( 't test', "t-value is %s, p=%s"%stats.ttest_1samp(sample, YOUR_POPULATION_MEAN))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多