The T-test is an inferential statistical method used to determine whether there is a significant difference between the means of two sets of data and the relationship between them.
The T-test is an inferential statistical method used to determine whether there is a significant difference between the means of two sets of data and the relationship between them. The T-test is used when the data set is normally distributed and has unknown variance, such as a data set recorded from 100 coin tosses.
The T-test is a test used in statistics for hypothesis testing that uses the t-statistic, t-distribution values, and degrees of freedom to determine statistical significance.
The T-test compares the means of two sets of data and determines whether they come from the same population. In the example above, it is unlikely that the sample of students from Class A and the sample of students from Class B will have the same mean and standard deviation. Likewise, samples drawn from a control group taking a placebo and a group taking a prescription drug should have slightly different means and standard deviations.
Mathematically, a T-test takes a sample from each of two sets and establishes a problem statement. It assumes a null hypothesis that the two means are equal.
Using formulas, values are calculated and compared with standard values. Accept or reject the hypothesized null hypothesis accordingly. If the null hypothesis qualifies for rejection, it indicates that the data reading is strong and may not be due to chance.
The T-test is just one of many tests used for this purpose. Statisticians use tests other than T-tests to examine more variables and larger sample sizes. For larger sample sizes, statisticians use z tests. Other testing options include the chi-square test and the f-test.
Suppose a pharmaceutical company tests a new drug. Following standard procedures, the drug is given to one group of patients and a placebo is given to another group, called the control group. A placebo is a substance with no therapeutic value that serves as a benchmark against which to measure the response of another group (taking the actual drug).
After the drug trial, members of the control group who took a placebo reported an average increase in life expectancy of three years, while members of the group who took the new drug reported an average increase of four years.
Preliminary observations suggest the drug is working. However, this observation could also be due to chance. T-tests can be used to determine whether the results are correct and apply to the entire population.
Four hypotheses are made when using a T-test. The data collected must follow a continuous or ordinal scale, such as scores on an IQ test, the data are collected from a randomly selected portion of the total population, the data will result in a normal distribution with a bell-shaped curve, and equal or homogeneous variances exist when the standard deviations are equal.
There are three basic data values required to calculate a T-test. They include the difference between the means of each data set (i.e., the mean difference), the standard deviation of each group, and the number of data values for each group.
This comparison helps determine the contribution of chance to the differences and whether the differences fall outside of that chance range. T-tests question whether differences between groups represent real differences in the study, or are simply random differences.
The T-test produces two values as its output: the t-value and the degrees of freedom. The t-value, or t-score, is the ratio of the difference between the means of two sample sets to the variation present within the sample sets.
The numerator value is the difference between the means of the two sample sets. The denominator is the variation present in the sample set and is a measure of dispersion or variability.
The calculated t-value is then compared with the value obtained from a table of critical values called the T-distribution table. A higher t-score indicates a larger difference between the two sample sets. The smaller the t value, the greater the similarity that exists between the two sample sets.
T-score: A larger t-score (or t-value) indicates that the groups are different, while a smaller t-score indicates that the groups are similar.
Degrees of freedom refer to the values that are free to vary in a study and are critical to assessing the significance and validity of the null hypothesis. The calculation of these values usually depends on the number of data records available in the sample set.
The correlated t-test or paired t-test is a dependent test that is performed when the sample consists of matched pairs of similar units, or when there are repeated measurements. For example, there may be situations where the same patient is tested repeatedly before and after receiving a specific treatment. Each patient was used as a control sample against himself.
This method is also suitable where the samples are related or have matching characteristics, such as comparative analyzes involving children, parents, or siblings.
The formula for calculating the t-value and degrees of freedom for a paired t-test is:
<!-- @@@ -->The equal variances t-test is an independent t-test used when the number of samples in each group is the same, or when the variances of the two data sets are similar.
The formula for calculating the t-value and degrees of freedom for an equal variance t-test is:
<!-- @@@ -->and,
<!-- @@@ -->The unequal variances t-test is an independent t-test used when the number of samples in each group is different and the variances of the two data sets are not the same. This test is also called Welch's t-test.
The formula for calculating the t-value and degrees of freedom for an unequal variances t-test is:
<!-- @@@ -->and,
<!-- @@@ -->The following flowchart can be used to determine which T-test to use based on the characteristics of your sample set. Key items to consider include the similarity of sample records, the number of data records in each sample set, and the variance of each sample set.
Suppose that a painting received by an art gallery is measured diagonally. One sample included 10 paintings, while the other included 20 paintings. The data set and its corresponding mean and variance values are as follows:
| Collection 1 | Collection 2 | |
|---|---|---|
| 19.7 | 28.3 | |
| 20.4 | 26.7 | |
| 19.6 | 20.1 | |
| 17.8 | 23.3 | |
| 18.5 | 25.2 | |
| 18.9 | 22.1 | |
| 18.3 | 17.7 | |
| 18.9 | 27.6 | |
| 19.5 | 20.6 | |
| 21.95 | 13.7 | |
| 23.2 | ||
| 17.5 | ||
| 20.6 | ||
| 18 | ||
| 23.9 | ||
| 21.6 | ||
| 24.3 | ||
| 20.4 | ||
| 23.9 | ||
| 13.3 | ||
| Average | 19.4 | 21.6 |
| Variance | 1.4 | 17.1 |
Although the mean of set 2 is higher than the mean of set 1, we cannot conclude that the population corresponding to set 1 has a higher mean than the population corresponding to set 1.
Is the difference from 19.4 to 21.6 simply due to chance, or is the difference present in the population of all paintings received by an art gallery? We frame the problem by assuming the null hypothesis that the means are the same between the two sample sets and conduct a T-test to test whether this hypothesis is reasonable.
Since the number of data records is different (n1 = 10 and n2 = 20) and the variances are also different, the t-value and degrees of freedom for the above data set are calculated using the formula mentioned in the Unequal Variances T-test section.
The t value is -2.24787. Since the negative sign can be ignored when comparing two t values, the calculated value is 2.24787.
The degrees of freedom value is 24.38, which is reduced to 24 because the formula definition requires that the value be rounded down to the smallest possible integer value.
Probability levels (alpha level, significance level, p) can be specified as acceptance criteria. In most cases, a value of 5% can be assumed.
Using a degree of freedom value of 24 and a significance level of 5%, looking at the t-value distribution table yields a value of 2.064. Comparing this value with the calculated value of 2.247 shows that the calculated t-value is greater than the table value at a significance level of 5%. Therefore, the null hypothesis that there is no difference between means can be safely rejected. Population sets are inherently different and are not caused by chance.
T-distribution tables are available in one-tailed and two-tailed formats. The former is used to evaluate situations with a fixed value or range and a clear direction (positive or negative). For example, what is the probability that the output value remains below -3, or what is the probability of getting more than 7 when rolling a pair of dice? The latter is used for range bound analysis, for example asking whether a coordinate falls between -2 and +2.
The samples for an independent T-test are selected independently of each other, where the data sets in the two groups do not reference the same values. They may consist of 100 randomly unrelated patients divided into two groups of 50 patients each. One group became the control group and received a placebo, while the other group received the prescribed treatment. This constitutes two independent groups of samples that are unpaired and unrelated to each other.
The T-test is a statistical test used to compare the means of two groups. It is often used for hypothesis testing to determine whether a procedure or treatment has an effect on the population of interest, or whether two groups are different from each other.
TheQuantHackers is a cutting-edge community composed of a group of people from the world's top universities and quantitative finance practitioners, dedicated to exploring the infinite possibilities in the fields of artificial intelligence (AI) and quantification (Quant). Our team members come from world-renowned universities such as the University of Cambridge, Oxford University, Harvard University, ETH Zurich, Peking University, and the University of Science and Technology of China. Our external consultants come from first-class companies such as Microsoft, HSBC, Citadel, Man Group, Citi, Jump Trading, and top domestic private equity companies.
等方差 t 检验是一种独立的 t 检验,当每组中的样本数量相同,或者两个数据集的方差相似时使用。
用于计算等方差 t 检验的 t 值和自由度的公式为:
T 检验是一种推论统计方法,用于确定两组数据的均值之间是否存在显著差异以及它们之间的关系。当数据集服从正态分布且具有未知方差时,例如从抛硬币 100 次记录的数据集,会使用 T 检验。
T 检验是统计学中用于假设检验的一种检验,它使用 t 统计量、t 分布值和自由度来确定统计显著性。
T 检验比较两组数据集的平均值,并确定它们是否来自同一总体。在上面的例子中,来自 A 班的学生样本和来自 B 班的学生样本不太可能具有相同的均值和标准差。同样,从服用安慰剂的对照组和服用处方药的组中抽取的样本应该具有略微不同的均值和标准差。
在数学上,T 检验从两个集合中的每一个中抽取一个样本,并建立问题陈述。它假设一个零假设,即两个均值相等。
使用公式,计算值并与标准值进行比较。相应地接受或拒绝假设的零假设。如果零假设符合被拒绝的条件,则表明数据读数很强,并且可能不是由于偶然性造成的。
T 检验只是用于此目的的众多检验之一。统计学家使用 T 检验以外的其他检验来检查更多变量和更大的样本量。对于较大的样本量,统计学家使用 z 检验。其他测试选项包括卡方检验和 f 检验。
假设一家制药公司测试一种新药。按照标准程序,将药物给予一组患者,将安慰剂给予另一组患者,称为对照组。安慰剂是一种没有治疗价值的物质,作为衡量另一组(服用实际药物)反应的基准。
药物试验后,服用安慰剂的对照组的成员报告平均预期寿命增加了三年,而服用新药的组的成员报告平均预期寿命增加了四年。
初步观察表明该药物正在发挥作用。然而,这种观察结果也可能是由于偶然性造成的。可以使用 T 检验来确定结果是否正确并适用于整个群体。
使用 T 检验时会做出四个假设。收集的数据必须遵循连续或有序的尺度,例如智商测试的分数,数据是从总人口中随机选择的一部分收集的,数据将导致钟形曲线的正态分布,并且当标准差相等时存在相等或同质的方差。
计算 T 检验需要三个基本数据值。它们包括每个数据集的平均值之间的差异(即平均差异)、每组的标准差以及每组的数据值数量。
这种比较有助于确定偶然性对差异的影响,以及差异是否超出该偶然性范围。T 检验会质疑组之间的差异是否代表研究中的真实差异,或者仅仅是随机差异。
T 检验产生两个值作为其输出:t 值和自由度。t 值,或 t 分数,是两个样本集的均值之间的差异与样本集内存在的变异的比率。
分子值是两个样本集的均值之间的差异。分母是样本集中存在的变异,是对离散度或变异性的度量。
然后将计算出的 t 值与从称为 T 分布表的临界值表中获得的值进行比较。t 分数越高,表明两个样本集之间存在较大差异。t 值越小,两个样本集之间存在的相似性就越大。
T 分数: 较大的 t 分数(或 t 值)表明组之间存在差异,而较小的 t 分数表明组之间相似。
自由度是指研究中可以自由变化的值,对于评估零假设的重要性和有效性至关重要。这些值的计算通常取决于样本集中可用的数据记录的数量。
相关 t 检验或配对 t 检验是一种依赖型检验,当样本由相似单元的匹配对组成,或者存在重复测量的情况时执行。例如,可能存在在接受特定治疗之前和之后重复测试同一患者的情况。每个患者都被用作针对自身的对照样本。
此方法也适用于样本相关或具有匹配特征的情况,例如涉及儿童、父母或兄弟姐妹的比较分析。
用于计算配对 t 检验的 t 值和自由度的公式为:
不等方差 t 检验是一种独立的 t 检验,当每组中的样本数量不同,并且两个数据集的方差也不同时使用。此检验也称为 Welch's t 检验。
用于计算不等方差 t 检验的 t 值和自由度的公式为:
等方差 t 检验是一种独立的 t 检验,当每组中的样本数量相同,或者两个数据集的方差相似时使用。
用于计算等方差 t 检验的 t 值和自由度的公式为:
以下流程图可用于根据样本集的特征确定要使用的 T 检验。要考虑的关键项目包括样本记录的相似性、每个样本集中的数据记录的数量以及每个样本集的方差。
假设对艺术画廊收到的画作进行对角线测量。一组样本包括 10 幅画作,而另一组包括 20 幅画作。数据集及其相应的均值和方差值如下:
| 集合 1 | 集合 2 | |
|---|---|---|
| 19.7 | 28.3 | |
| 20.4 | 26.7 | |
| 19.6 | 20.1 | |
| 17.8 | 23.3 | |
| 18.5 | 25.2 | |
| 18.9 | 22.1 | |
| 18.3 | 17.7 | |
| 18.9 | 27.6 | |
| 19.5 | 20.6 | |
| 21.95 | 13.7 | |
| 23.2 | ||
| 17.5 | ||
| 20.6 | ||
| 18 | ||
| 23.9 | ||
| 21.6 | ||
| 24.3 | ||
| 20.4 | ||
| 23.9 | ||
| 13.3 | ||
| 平均值 | 19.4 | 21.6 |
| 方差 | 1.4 | 17.1 |
虽然集合 2 的平均值高于集合 1 的平均值,但我们不能得出结论:与集合 1 对应的总体比与集合 1 对应的总体具有更高的平均值。
从 19.4 到 21.6 的差异仅仅是由于偶然性造成的,还是艺术画廊收到的所有画作的总体中存在差异?我们通过假设零假设(即两个样本集之间的平均值相同)来建立问题,并进行 T 检验以测试该假设是否合理。
由于数据记录的数量不同(n1 = 10 且 n2 = 20),并且方差也不同,因此使用不等方差 T 检验部分中提到的公式计算上述数据集的 t 值和自由度。
t 值为 -2.24787。由于在比较两个 t 值时可以忽略负号,因此计算值为 2.24787。
自由度值为 24.38,由于公式定义要求将该值向下舍入到最小可能的整数值,因此将其减少到 24。
可以指定概率水平(alpha 水平、显著性水平、p)作为接受的标准。在大多数情况下,可以假设 5% 的值。
使用自由度值 24 和 5% 的显著性水平,查看 t 值分布表得出值为 2.064。将此值与计算值 2.247 进行比较表明,计算出的 t 值大于显著性水平为 5% 的表值。因此,可以安全地拒绝均值之间没有差异的零假设。总体集具有内在差异,并且不是偶然造成的。
T 分布表有单尾和双尾格式。前者用于评估具有固定值或范围且具有明确方向(正或负)的情况。例如,输出值保持在 -3 以下的概率是多少,或者掷一对骰子时获得超过 7 的概率是多少?后者用于范围界限分析,例如询问坐标是否落在 -2 和 +2 之间。
独立 T 检验的样本是彼此独立选择的,其中两组中的数据集不引用相同的值。它们可能包括 100 名随机不相关的患者,分为两组,每组 50 名患者。其中一组成为对照组并服用安慰剂,而另一组接受处方治疗。这构成了两个独立的样本组,它们是不成对且彼此无关的。
T 检验是一种统计检验,用于比较两组的均值。它通常用于假设检验,以确定过程或治疗是否对感兴趣的总体产生影响,或者两组是否彼此不同。
TheQuantHackers是由一群来自世界顶尖高校和量化金融从业人员组成的前沿社区,致力于探索人工智能(AI)与量化(Quant)领域的无限可能。我们的团队成员来自剑桥大学、牛津大学、哈佛大学、苏黎世联邦理工学院、北京大学、中科大等世界知名高校,外部顾问来自Microsoft、HSBC、Citadel、Man Group、Citi、Jump Trading、国内顶尖私募等一流企业。
Upgrade to unlock all institutional-grade algorithms, derivative pricing engines, factor backtesting frameworks, and live QuantLab execution.
Explore Membership Access
Pre-order · £490Quantitative analytics platform
Waitlist closed — signal locked. Pre-order TQH TERMINAL now at £490 with launch-day delivery.