vartest2
Two-sampleF- 相等差异的测试
Syntax
描述
返回对向量中数据的零假设的测试决定h
= vartest2(x
,y
)x
和y
来自具有相同差异的正常分布,使用两个样本F-test. The alternative hypothesis is that they come from normal distributions with different variances. The resulth
是1
if the test rejects the null hypothesis at the 5% significance level, and0
otherwise.
返回两个样本的测试决定F- 通过一个或多个名称值对参数指定的其他选项。例如,您可以更改显着性水平或进行单方面测试。h
= vartest2(x
,y
,Name,Value
)
例子
Test for Equal Variances
加载样本数据。创建包含数据矩阵的第一和第二列的向量,以表示学生和两次考试的成绩。
load考试; x = grades(:,1); y = grades(:,2);
Test the null hypothesis that the data inx
和y
comes from distributions with the same variance.
[h,p,ci,stats] = vartest2(x,y)
h = 1
p = 0.0019
CI =2×11.2383 2.5494
stats =带有字段的结构:fstat: 1.7768 df1: 119 df2: 119
The returned resulth = 1
表示这vartest2
rejects the null hypothesis at the default 5% significance level.ci
包含真正方差比的95%置信区间的下限和上限。stats
contains the value of the test statistic for the
-test and the numerator and denominator degrees of freedom.
单方假设检验
加载样本数据。创建包含数据矩阵的第一和第二列的向量,以代表两次考试的学生成绩。
load考试; x = grades(:,1); y = grades(:,2);
Test the null hypothesis that the data inx
和y
comes from distributions with the same variance, against the alternative that the population variance ofx
大于y
.
vartest2(x,y,'Tail','正确的')
ans = 1
The returned resulth = 1
表示这vartest2
拒绝默认值为5%的显着性水平的无效假设,而有利于另一种假设,即种群差异x
大于y
.
Input Arguments
x
—样本数据
vector|matrix|多维阵列
示例数据,指定为矢量,矩阵或多维阵列.
如果
x
和y
是向量,它们不需要相同的长度。如果
x
和y
are matrices, they must have the same number of columns, but do not need to have the same number of rows.vartest2
performs separate tests along each column and returns a vector of the results.如果
x
和y
are multidimensional arrays, they must have the same number of dimensions, and the same size along all but the第一个nonsingleton维度.
Data Types:single
|双倍的
y
—样本数据
vector|matrix|多维阵列
示例数据,指定为矢量,矩阵或多维阵列.
如果
x
和y
是向量,它们不需要相同的长度。如果
x
和y
are matrices, they must have the same number of columns, but do not need to have the same number of rows.vartest2
performs separate tests along each column and returns a vector of the results.如果
x
和y
are multidimensional arrays, they must have the same number of dimensions, and the same size along all but the第一个nonsingleton维度.
Data Types:single
|双倍的
Name-Value Arguments
将可选的参数对Name1=Value1,...,NameN=ValueN
, whereName
是the argument name and价值
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
例子:“尾巴”,“右”,“ alpha”,0.01
specifies a right-tailed hypothesis test at the 1% significance level.
Alpha
—Significance level
0.05
(default) |scalar value in the range (0,1)
假设检验的显着性水平,指定为逗号分隔对'Α'
和a scalar value in the range (0,1).
例子:'alpha',0.01
Data Types:single
|双倍的
Dim
—方面
第一个nonsingleton维度(default) |正整数值
输入矩阵的维度进行测试,指定为逗号分隔对'Dim'
和a positive integer value. For example, specifying'Dim',1
测试每列中的数据是否方差平等,而'Dim',2
测试每一行中的数据。
例子:'Dim',2
Data Types:single
|双倍的
Tail
—Type of alternative hypothesis
'both'
(default) |'正确的'
|'剩下'
Type of alternative hypothesis to evaluate using theF-test, specified as the comma-separated pair consisting of'Tail'
和one of the following.
'both' |
测试人口差异不相等的替代假设。 |
'正确的' |
Test the alternative hypothesis that the population variance ofx 大于y . |
'剩下' |
Test the alternative hypothesis that the population variance ofx 小于y . |
例子:'Tail','right'
Output Arguments
h
— Hypothesis test result
1
|0
Hypothesis test result, returned as1
或者0
.
如果
h
= 1
, this indicates the rejection of the null hypothesis at theAlpha
significance level.如果
h
= 0
, this indicates a failure to reject the null hypothesis at theAlpha
significance level.
p
—p-value
scalar value in the range [0,1]
p- 测试值,在[0,1]范围内作为标量值返回。p
是the probability of observing a test statistic as extreme as, or more extreme than, the observed value under the null hypothesis. Small values ofp
对零假设的有效性产生怀疑。
ci
— Confidence interval
vector
Confidence interval for the true ratio of the population variances, returned as a two-element vector containing the lower and upper boundaries of the 100 × (1 –Alpha
)置信区间%。
stats
- 测试统计
结构体
假设检验的测试统计量,返回为包含的结构:
fstat
- 测试统计量的价值。DF1
- 测试的分子自由度。DF2
- 分母测试自由度。
More About
Two-SampleF-Test
The two-sampleF- 检验用于测试两个人群的方差是否相等。
The test statistic is
wheres1和s2are the sample standard deviations. The test statistic is a ratio of the two sample variances. The further this ratio deviates from 1, the more likely you are to reject the null hypothesis. Under the null hypothesis, the test statisticF有个F-distribution with numerator degrees of freedom equal toN1- 1和分母的自由度等于N2- 1,哪里N1和N2are the sample sizes of the two data sets.
Multidimensional Array
多维阵列具有两个以上的维度。例如,如果x
是a 1-by-3-by-4 array, thenx
是一个三维阵列。
First Nonsingleton Dimension
第一个nonsingleton维度是大小不等于1的数组的第一个维度。例如,如果x
是a 1-by-2-by-3-by-4 array, then the second dimension is the first nonsingleton dimension ofx
.
Extended Capabilities
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
此功能完全支持GPU数组。金宝app有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox).
版本历史
开放示例
You have a modified version of this example. Do you want to open this example with your edits?
matlab命令
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)