The one-sample t-test is a statistical hypothesis test used to determine whether an unknown population mean is different from a specific value.

Here is an example: 我们想知道601班的平均身高是否是170cm。

适用条件

  • Independent (values are not related to one another).
  • Continuous.
  • Obtained via a simple random sample from the population.

示例代码

MATLAB

函数:ttest

比较x的均值是否等于75

1
h = ttest(x,75)

比较x的均值是否大于等于75(小于等于75)

1
2
[h,p] = ttest(x,75,"Tail","right") % H1: mean of x is greater than 75
[h,p] = ttest(x,75,"Tail","left") % H1: mean of x is smaller than 75

h为是否拒绝原假设

  • If h = 1, this indicates the rejection of the null hypothesis at the Alpha significance level.

  • If h = 0, this indicates a failure to reject the null hypothesis at the Alpha significance level.

p为p-value

R

1
dfd

Python

1
s