After completing this tutorial, you will know:

  • The Student’s t-test for quantifying the difference between the mean of two independent data samples.
  • The paired Student’s t-test for quantifying the difference between the mean of two dependent data samples.
  • The ANOVA and repeated measures ANOVA for checking the similarity or difference between the means of 2 or more data samples.

1.1 Tutorial Overview

1.Parametric Statistical Significance Tests

2.Test Data

3. Student t-Test

4. Paired Student's t-Test

5.Analysis of Variance Test

6.Repeated Measures ANOVA Test

1.2 Parametric Statistical Significance Tests

Parametric statistical tests assume that a data sample was drawn from a specific population distribution. They often refer to statistical tests that assume the Gaussian distribution. Because it is so common for data to fit this distribution, parametric statistical methods are more commonly used. A typical question we may have about two or more samples of data is whether they have the same distribution. Parametric statistical significance tests are those statistical methods that assume data comes from the same Gaussian distribution, that is a data distribution with the same mean and standard deviation: the parameters of the distribution.

In general, each test calculates a test statistic that must be interpreted with some background in statistics and a deeper knowledge of the statistical test itself. Tests also return a p-value that can be used to interpret the result of the test. The p-value can be thought of as the probability of observing the two data samples given the base assumption (null hypothesis) that the two samples were drawn from a population with the same distribution. The p-value can be interpreted in the context of a chosen significance level called alpha. A common value for alpha is 5%, or 0.05. If the p-value is below the significance level, then the test says there is enough evidence to reject the null hypothesis and that the samples were likely drawn from populations with differing distributions.

  • p-value ≤ alpha: significant result, reject null hypothesis (H0), distributions differ.
  • p-value > alpha: not significant result, fail to reject null hypothesis (H0), distributions same.

1.3 Test Data

Before we look at specific parametric significance tests, let’s first define a test dataset that we can use to demonstrate each test. We will generate two samples drawn from different distributions. Each sample will be drawn from a Gaussian distribution. We will use the randn() NumPy function to generate a sample of 100 Gaussian random numbers in each sample with a mean of 0 and a standard deviation of 1. Observations in the first sample are scaled to have a mean of 50 and a standard deviation of 5. Observations in the second sample are scaled to have a mean of 51 and a standard deviation of 5.

We expect the statistical tests to discover that the samples were drawn from differing distributions, although the small sample size of 100 observations per sample will add some noise to this decision. The complete code example is listed below.

# generate gaussian data samples
from numpy.random import seed
from numpy.random import randn
from numpy import mean
from numpy import std
# seed the random number generator
seed(1)
# generate two sets of univariate observations
data1 = 5 * randn(100) + 50
data2 = 5 * randn(100) + 51
# summarize
print('data1: mean=%.3f stdv=%.3f' % (mean(data1),std(data1)))
print('data2: mean=%.3f stdv=%.3f' % (mean(data2),std(data2)))

Running the example generates the data samples, then calculates and prints the mean and standard deviation for each sample, confirming their different distribution.

1.4 Student's t-Test

The Student’s t-test is a statistical hypothesis test that two independent data samples known to have a Gaussian distribution, have the same Gaussian distribution, named for William Gosset, who used the pseudonym Student.

One of the most commonly used t-tests is the independent samples t-test. You use this test when you want to compare the means of two independent samples on a given variable.

The assumption or null hypothesis of the test is that the means of two populations are equal. A rejection of this hypothesis indicates that there is sufficient evidence that the means of the populations are different, and in turn that the distributions are not equal.

  • Fail to Reject H0: No difference between the sample means.
  • Reject H0: Some difference between the sample means.

The Student’s t-test is available in Python via the ttest ind() SciPy function. The function takes two data samples as arguments and returns the calculated statistic and p-value. The test assumes that both samples have the same variance, if this is not the case, a corrected version of the test can be used by setting the equal_var to False. We can demonstrate the Student’s t-test on the test problem with the expectation that the test discovers the difference in distribution between the two independent samples. The complete code example is listed below.

# student's t-test
from numpy.random import seed
from numpy.random import randn
from scipy.stats import ttest_ind
# seed the random number generator
seed(1)
# generate two independent samples
data1 = 5 * randn(100) + 50
data2 = 5 * randn(100) + 51
# compare samples
stat,p = ttest_ind(data1, data2)
print('Statistics=%.3f,p=%.3f' %(stat, p))
# interpret
alpha = 0.05
if p > alpha:print('Same distribution (fail to reject H0)')
else:print('Different distributions (reject H0)')

Running the example calculates the Student’s t-test on the generated data samples and prints the statistic and p-value. The interpretation of the statistic finds that the sample means are different, with a significance of at least 5%.

1.5 Paired Student's t-Test

We may wish to compare the means between two data samples that are related in some way. For example, the data samples may represent two independent measures or evaluations of the same object. These data samples are repeated or dependent and are referred to as paired samples or repeated measures. Because the samples are not independent, we cannot use the Student’s t-test. Instead, we must use a modified version of the test that corrects for the fact that the data samples are dependent, called the paired Student’s t-test.

A dependent samples t-test is also used to compare two means on a single dependent variable. Unlike the independent samples test, however, a dependent samples t-test is used to compare the means of a single sample or of two matched or paired samples.

The test is simplified because it no longer assumes that there is variation between the observations, that observations were made in pairs, before and after a treatment on the same subject or subjects. The default assumption, or null hypothesis of the test, is that there is no difference in the means between the samples. The rejection of the null hypothesis indicates that there is enough evidence that the sample means are different.

  • Fail to Reject H0: Paired sample distributions are equal
  • Reject H0: Paired sample distributions are not equal.

The paired Student’s t-test can be implemented in Python using the ttest rel() SciPy function. As with the unpaired version, the function takes two data samples as arguments and returns the calculated statistic and p-value. We can demonstrate the paired Student’s t-test on the test dataset. Although the samples are independent, not paired, we can pretend for the sake of the demonstration that the observations are paired and calculate the statistic. The complete example is listed below

# paired student's t-test
from numpy.random import seed
from numpy.random import randn
from scipy.stats import ttest_rel
#seed the random number generator
seed(1)
# generate two independent samples
data1 = 5 * randn(100) + 50
data2 = 5 * randn(100) + 51
# compare samples
stat,p = ttest_rel(data1, data2)
print('Statistics=%.3f,p=%.3f' %(stat, p))
# interpret
alpha = 0.05
if p > alpha:print('Same distributions (fail to reject H0)')
else:print('Different distributions (reject H0)')

Running the example calculates and prints the test statistic and p-value. The interpretation of the result suggests that the samples have different means and therefore different distributions

1.6 Analysis of Variance Test

There are sometimes situations where we may have multiple independent data samples. We can perform the Student’s t-test pairwise on each combination of the data samples to get an idea of which samples have different means. This can be onerous if we are only interested in whether all samples have the same distribution or not. To answer this question, we can use the analysis of variance test, or ANOVA for short. ANOVA is a statistical test that assumes that the mean across 2 or more groups are equal. If the evidence suggests that this is not the case, the null hypothesis is rejected and at least one data sample has a different distribution.

  • Fail to Reject H0: All sample distributions are equal.
  • Reject H0: One or more sample distributions are not equal.

Importantly, the test can only comment on whether all samples are the same or not; it cannot quantify which samples differ or by how much.

The test requires that the data samples are a Gaussian distribution, that the samples are independent, and that all data samples have the same standard deviation. The ANOVA test can be performed in Python using the f_oneway() SciPy function. The function takes two or more data samples as arguments and returns the test statistic and f-value. We can modify our test problem to have two samples with the same mean and a third sample with a slightly different mean. We would then expect the test to discover that at least one sample has a different distribution. The complete example is listed below.

# analysis of variance test
from numpy.random import seed
from numpy.random import randn
from scipy.stats import f_oneway
# seed the random number generator
seed(1)
# generate three independent samples
data1 = 5 * randn(100) + 50
data2 = 5 * randn(100) + 50
data3 = 5 * randn(100) + 52
# compare samples
stat, p = f_oneway(data1, data2, data3)
print('Statistics=%.3f, p=%.3f' % (stat, p))
# interpret
alpha = 0.05
if p > alpha:print('Same distributions (fail to reject H0)')
else:print('Different distributions (reject H0)')

Running the example calculates and prints the test statistic and the p-value. The interpretation of the p-value correctly rejects the null hypothesis indicating that one or more sample means differ.

1.7 Repeated Measures ANOVA Test

We may have multiple data samples that are related or dependent in some way. For example, we may repeat the same measurements on a subject at different time periods. In this case, the samples will no longer be independent; instead we will have multiple paired samples. We could repeat the pairwise Student’s t-test multiple times. Alternately, we can use a single test to check if all of the samples have the same mean. A variation of the ANOVA test can be used, modified to test across more than 2 samples. This test is called the repeated measures ANOVA test. The default assumption or null hypothesis is that all paired samples have the same mean, and therefore the same distribution. If the samples suggest that this is not the case, then the null hypothesis is rejected and one or more of the paired samples have a different mean.

  • Fail to Reject H0: All paired sample distributions are equal.
  • Reject H0: One or more paired sample distributions are not equal.

Repeated-measures ANOVA has a number of advantages over paired t-tests, however. First, with repeated-measures ANOVA, we can examine differences on a dependent variable that has been measured at more than two time points, whereas with an independent t-test we can only compare scores on a dependent variable from two time points.

About Significance Tests相关推荐

  1. Paper:《A Few Useful Things to Know About Machine Learning—关于机器学习的一些有用的知识》翻译与解读

    Paper:<A Few Useful  Things to  Know About  Machine  Learning-关于机器学习的一些有用的知识>翻译与解读 目录 <A Fe ...

  2. NLP之路-Dataset大全

    The Enron corpus with an extensive annotation of organizational hierarchy. http://www1.ccls.columbia ...

  3. 用一年的数据预测下一年数据_一年的招聘数据中的经验教训

    用一年的数据预测下一年数据 by Aline Lerner 通过艾琳·勒纳(Aline Lerner) 一年的招聘数据中的经验教训 (Lessons from a year's worth of hi ...

  4. 自动白平衡也即:color constancy (色彩恒常)研究总结

    对camera 进行   自动白平衡也即:color constancy (色彩恒常) ,有很多方法, 在"Computational Color Constancy: Survey and ...

  5. 明翰全日制英国硕士学术写作V0.1(持续更新)

    明翰全日制英国硕士学术写作V0.1(持续更新) 文章目录 传送门 PAP学术写作 `批判性思维` 定义解释 `Position` Reason Evidence Argument Rebuttal ` ...

  6. 强化学习基础(第一周)笔记和代码(RL-cousera)

    K-摇臂赌博机 问题定义 K-摇臂赌博机有K个摇臂,赌徒在投入一个硬币后可选择按下其中一个摇臂,每个摇臂以一定的概率吐出硬币,但这个概率赌徒并不知道.赌徒的目标是通过一定的策略最大化自己的奖赏,即获得 ...

  7. 明翰全日制英国硕士留学攻略V2.7(持续更新)

    文章目录 传送门 前言 1. 留学准备 1.1 `留学原因` 1.2 选择国家 1.3 `选择中介` 1.4 `选择学校与专业` `offer` 1.4.1 预科 1.4.2 `1年制与2年制` 1. ...

  8. Nature子刊:周集中团队揭示气候变暖增强了微生物网络的复杂性与稳定性

    气候变暖增强了微生物网络的复杂性与稳定性 Climate warming enhances microbial network complexity and stability Nature Clim ...

  9. 相关系数和相关性分析(上):皮尔逊相关系数、斯皮尔曼相关系数

    专注系列化.高质量的R语言教程 推文索引 | 联系小编 | 付费合集 我们最常用的相关系数是皮尔逊(Pearson)相关系数,也叫简单相关系数,用来衡量两个配对连续变量的线性相关程度.此外,还有斯皮尔 ...

最新文章

  1. 测试与封装5.1.5.2
  2. iOS 自定义返回按钮,保留系统滑动返回
  3. pandas一维度数据操作
  4. **Java有哪些悲观锁的实现_80% 人不知道的 Redis 分布式锁的正确实现方式(Java 版)...
  5. mini-treeselect的动态赋值
  6. PHP程序员的技术成长规划(转)
  7. www.opensymphony.com - Class: java.net.PlainSocketImpl
  8. 26.多线程join detach
  9. 史上最惨锦鲤即将来袭!奖品堪比5年高考3年模拟!
  10. qt和c#怎么选_请问目前做windows桌面应用程序,MFC、QT、C#哪个更好?
  11. 利用矩阵的n次方求图的连通性
  12. IOS NSNotification 通知
  13. 面向对象三大特性——多态
  14. 基于UNITY引擎开发的游戏源码修改方法
  15. ilo远程给服务器装系统,惠普hp服务器通过iLO接口远程安装操作系统
  16. 不会安装Maya的同学看过来,安装步骤详解
  17. SHOWWINDOW最小化不好用
  18. 网络语言3c是什么意思,2017网络流行语大全:这些网络新词你知道吗
  19. 「津津乐道播客」#380 津津有味:厨房重地举目皆是刚需,将就不得
  20. php 字符查询_php中几个常用的字符串查找函数

热门文章

  1. 协同过滤推荐算法:UserCF、ItemCF python现实
  2. 轩辕剑-天之痕java_轩辕剑天之痕,芦家渡的宝藏当年有多少玩家得到过?
  3. Android应用开发--MP3音乐播放器滚动歌词实现,flutter跳转动画
  4. Java开发:刚刚入职的Java程序员必做的几件事
  5. 印度富士康的iPhone产能在扩产,对中国制造将产生深远影响
  6. 网易云信发布两大元宇宙解决方案,打响进军元宇宙第一枪
  7. 如何使用jupyter进行数据分析
  8. python操作excle表格
  9. CortexA7工业级迅为-iMX6UL开发板硬件和资料介绍
  10. 微软副总裁尤瑟夫·梅赫迪对必应和“病”同音的解释