官术网_书友最值得收藏!

Z-test vs T-test

We have already done a few Z-tests before where we validated our null hypothesis.

Z-test vs T-test

A T-distribution is similar to a Z-distribution—it is centered at zero and has a basic bell shape, but its shorter and flatter around the center than the Z-distribution.

The T-distributions' standard deviation is usually proportionally larger than the Z, because of which you see the fatter tails on each side.

The t distribution is usually used to analyze the population when the sample is small.

The Z-test is used to compare the population mean against a sample or compare the population mean of two distributions with a sample size greater than 30. An example of a Z-test would be comparing the heights of men from different ethnicity groups.

The T-test is used to compare the population mean against a sample, or compare the population mean of two distributions with a sample size less than 30, and when you don't know the population's standard deviation.

Let's do a T-test on two classes that are given a mathematics test and have 10 students in each class:

>>> class1_score = np.array([45.0, 40.0, 49.0, 52.0, 54.0, 64.0, 36.0, 41.0, 42.0, 34.0])

>>> class2_score = np.array([75.0, 85.0, 53.0, 70.0, 72.0, 93.0, 61.0, 65.0, 65.0, 72.0])

To perform the T-test, we can use the ttest_ind() function in the SciPy package:

>>> stats.ttest_ind(class1_score,class2_score)

(array(-5.458195056848407), 3.4820722850153292e-05)

The first value in the output is the calculated t-statistics, whereas the second value is the p-value and p-value shows that the two distributions are not identical.

主站蜘蛛池模板: 南宫市| 宜黄县| 吉首市| 崇文区| 开化县| 米易县| 英吉沙县| 鸡西市| 舟山市| 满城县| 顺义区| 南岸区| 深州市| 罗定市| 章丘市| 海口市| 油尖旺区| 库尔勒市| 六枝特区| 珲春市| 类乌齐县| 沂水县| 普洱| 肥城市| 永嘉县| 南漳县| 广德县| 贵定县| 安国市| 阿拉善盟| 潞城市| 密云县| 阿拉尔市| 若羌县| 阿拉尔市| 泸州市| 壶关县| 凭祥市| 筠连县| 富阳市| 营山县|