ttest2
两个样本t-测试
句法
Description
returns a test decision for the null hypothesis that the data in vectorsH
= ttest2(X
,,,,y
)X
andy
使用平等平等和相等但未知方差的独立随机样本,使用two-samplet-测试。另一种假设是数据中的数据X
andy
来自具有不平等手段的人口。结果H
is1
如果该测试在5%的显着性水平上拒绝零假设,并且0
否则。
returns a test decision for the two-samplet- 通过一个或多个名称值对参数指定的其他选项。例如,您可以在不假设相等方差的情况下更改显着性水平或进行测试。H
= ttest2(X
,,,,y
,,,,姓名,,,,Value
)
Examples
两个样本t-Test for Equal Means
Load the data set. Create vectors containing the first and second columns of the data matrix to represent students’ grades on two exams.
加载examgradesx =级别(:,1);y =等级(:,2);
测试两个数据样本来自均值相等的人群的零假设。
[[H,,,,p,,,,CI,,,,stats] = ttest2(x,y)
h = 0
p = 0.9867
CI=2×1-1.9438 1.9771
统计=struct with fields:TSTAT:0.0167 DF:238 SD:7.7084
返回的值h = 0
表示这ttest2
does not reject the null hypothesis at the default 5% significance level.
t-Test for Equal Means Without Assuming Equal Variances
Load the data set. Create vectors containing the first and second columns of the data matrix to represent students’ grades on two exams.
加载examgradesx =级别(:,1);y =等级(:,2);
Test the null hypothesis that the two data vectors are from populations with equal means, without assuming that the populations also have equal variances.
[h,p] = ttest2(X,,,,y,,,,'vartype',,,,'不等')
h = 0
p = 0.9867
返回的值h = 0
表示这ttest2
即使不假定相等的差异,也不会在默认的5%显着性水平下拒绝零假设。
Input Arguments
X
-Sample data
向量|矩阵|multidimensional array
示例数据,指定为矢量,矩阵或多维数组。ttest2
零食南
值为缺少数据并忽略它们。
If
X
andy
被指定为向量,它们不需要相同的长度。If
X
andy
are specified as matrices, they must have the same number of columns.ttest2
执行单独t-测试along each column and returns a vector of results.If
X
andy
are specified as多维阵列,除了所有人之外,它们都必须具有相同的大小第一个nonsingleton维度。
数据类型:单身的
|double
y
-Sample data
向量|矩阵|multidimensional array
示例数据,指定为矢量,矩阵或多维数组。ttest2
零食南
值为缺少数据并忽略它们。
If
X
andy
被指定为向量,它们不需要相同的长度。If
X
andy
are specified as matrices, they must have the same number of columns.ttest2
执行单独t-测试along each column and returns a vector of results.If
X
andy
are specified as多维阵列,除了所有人之外,它们都必须具有相同的大小第一个nonsingleton维度。ttest2
works along the first nonsingleton dimension.
数据类型:单身的
|double
名称值参数
Specify optional pairs of arguments asname1 = value1,...,namen = valuen
,,,,在哪里姓名
是参数名称和Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
在R2021a之前,请使用逗号分隔每个名称和值,并附上姓名
用引号。
Example:'尾巴',,,,'正确的',,,,'Alpha',0.01,'Vartype','unequal'
specifies a right-tailed test at the 1% significance level, and does not assume thatX
andy
人口差异相等。
Alpha
-显着性水平
0.05
(默认)|scalar value in the range (0,1)
显着性水平of the hypothesis test, specified as the comma-separated pair consisting of'Alpha'
以及范围内的标量值(0,1)。
Example:'Alpha',0.01
数据类型:单身的
|double
暗淡
-暗淡ension
第一个nonsingleton维度(默认)|positive integer value
输入矩阵的尺寸,该矩阵测试均值,指定为逗号分隔对'Dim'
和积极的整数价值。例如,指定“昏暗”,1
测试列的含义,而“昏暗”,2
tests the row means.
Example:“昏暗”,2
数据类型:单身的
|double
尾巴
-替代假设的类型
'两个都'
(默认)|'正确的'
|'left'
评估的替代假设类型,指定为逗号分隔对'尾巴'
and one of:
ttest2
tests the null hypothesis that the population means are equal against the specified alternative hypothesis.
Example:'尾巴',,,,'正确的'
Vartype
-Variance type
'equal'
(默认)|'不等'
方差类型,指定为逗号分隔对,由'vartype'
以及以下内容之一。
'equal' |
Conduct test using the assumption thatX andy 来自具有未知但相等方差的正常分布。 |
'不等' |
Conduct test using the assumption thatX andy are from normal distributions with unknown and unequal variances. This is called the Behrens-Fisher problem.ttest2 将萨特沃特的近似值用于有效的自由度。 |
Vartype
即使X
是矩阵或多维阵列。
Example:“ vartype”,“不平等”
输出参数
H
- 假设检验结果
1
|0
假设测试结果,返回1
或者0
。
If
H
=1
,,,,tHis indicates the rejection of the null hypothesis at theAlpha
significance level.If
H
=0
,这表明未能拒绝在Alpha
significance level.
p
-p-价值
scalar value in the range [0,1]
p-价值of the test, returned as a scalar value in the range [0,1].p
观察测试统计量的概率比原假设下观察到的值更为极端或更极端。小值p
cast doubt on the validity of the null hypothesis.
统计
-Test statistics
结构体
两样本的测试统计数据t-测试,,,,returned as a structure containing the following:
TSTAT
-Value of the test statistic.DF
-Degrees of freedom of the test.SD
-Pooled estimate of the population standard deviation (for the equal variance case) or a vector containing the unpooled estimates of the population standard deviations (for the unequal variance case).
更多关于
两个样本t-测试
两个样本t- 检验是一个参数测试,比较了两个独立数据样本的位置参数。
The test statistic is
在哪里 and 是样本手段,sXandsyare the sample standard deviations, andnandm是样本量。
In the case where it is assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has Student'st分配n+m– 2自由度和样本标准偏差被合并的标准偏差所取代
In the case where it is not assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has an approximate Student'stSatterthwaite的近似值给出了许多自由度的分布。该测试有时称为韦尔奇t-测试。
Multidimensional Array
多维阵列具有两个以上的维度。例如,如果X
是一个1 x-3 x-4阵列,然后X
is a three-dimensional array.
第一个nonsingleton维度
The first nonsingleton dimension is the first dimension of an array whose size is not equal to 1. For example, ifX
是一个1 x-2-by-3-by-4阵列,那么第二维是第一个非元素维度。X
。
Tips
Use
sampsizepwr
计算:对应于指定的功率和参数值的样本大小;
给定真实参数值,对于特定样本量获得的功率;
参数值可通过指定的样本量和功率检测到。
扩展功能
GPU数组
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see在GPU上运行MATLAB功能(并行计算工具箱)。
版本历史记录
也可以看看
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
您单击了与此MATLAB命令相对应的链接:
运行该命令通过输入MATLAB逗号nd Window. Web browsers do not support MATLAB commands.
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
Americas
- AméricaLatina(Español)
- Canada((英语)
- United States((英语)