两独立样本T检验的matlab命令ttest2
(2008-12-30 17:24:52)
标签:
杂谈 |
分类: matlab学习 |
ttest2
Hypothesis testing for the difference in means of two samples
Syntax[h,significance,ci] = ttest2(x,y)
[h,significance,ci] = ttest2(x,y,alpha)
[h,significance,ci,stats] = ttest2(x,y,alpha)
[...] = ttest2(x,y,alpha,tail)
h =
ttest2(x,y,alpha,tail,'unequal')
Descriptionh =
ttest2(x,y) performs a t-test to determine whether two samples from
a normal distribution (in x and y) could have the same mean when
the standard deviations are unknown but assumed equal. The vectors
x and y can have different lengths. The result, h, is 1 if you can
reject the null hypothesis that the means are equal at the 0.05
significance level and 0 otherwise. significance is the p-value
associated with the t-statistic
[h,significance,ci] = ttest2(x,y,alpha) gives control of the significance level alpha. For example if alpha = 0.01, and the result, h, is 1, you can reject the null hypothesis at the significance level 0.01. ci in this case is a 100(1 - alpha)% confidence interval for the true difference in means.
[h,significance,ci,stats] = ttest2(x,y,alpha) returns a structure stats with the following three fields: tstat -- Value of the test statistic df -- Degrees of freedom of the test 'sd' -- Pooled estimate of the population standard deviation in the equal variance case, or a vector containing the unpooled estimates of the population standard deviations in the unequal variance case
[...] = ttest2(x,y,alpha,tail) allows specification of one- or
two-tailed tests, where tail is a flag that specifies one of three
alternative hypotheses: tail = 'both' specifies the
alternative
y = normrnd(0.5,1,100,1);
[h,significance,ci] = ttest2(x,y)
h =
significance =
ci =
The result h = 1 means that you can reject the null hypothesis. The
significance is 0.0017, which means that by chance you would have
observed values of t more extreme than the one in this example in
only 17 of 10,000 similar experiments! A 95% confidence interval on
the mean is [-0.7352 -0.1720], which includes the theoretical (and
hypothesized) difference of -0.5.