mars.tensor.stats.ttest_ind

mars.tensor.stats.ttest_ind(a, b, axis=0, equal_var=True, alternative='two-sided')[源代码]

Calculate the T-test for the means of two independent samples of scores.

This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values. This test assumes that the populations have identical variances by default.

参数
  • a (array_like) – The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).

  • b (array_like) – The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).

  • axis (int or None, optional) – Axis along which to compute test. If None, compute over the whole arrays, a, and b.

  • equal_var (bool, optional) – If True (default), perform a standard independent 2 sample test that assumes equal population variances 1. If False, perform Welch’s t-test, which does not assume equal population variance 2.

  • nan_policy ({'propagate', 'raise', 'omit'}, optional) –

    Defines how to handle when input contains nan. The following options are available (default is ‘propagate’):

    • ’propagate’: returns nan

    • ’raise’: throws an error

    • ’omit’: performs the calculations ignoring nan values

  • alternative ({'two-sided', 'less', 'greater'}, optional) –

    Defines the alternative hypothesis. The following options are available (default is ‘two-sided’):

    • ’two-sided’

    • ’less’: one-sided

    • ’greater’: one-sided

返回

  • statistic (float or array) – The calculated t-statistic.

  • pvalue (float or array) – The two-tailed p-value.

提示

We can use this test, if we observe two independent samples from the same or different population, e.g. exam scores of boys and girls or of two ethnic groups. The test measures whether the average (expected) value differs significantly across samples. If we observe a large p-value, for example larger than 0.05 or 0.1, then we cannot reject the null hypothesis of identical average scores. If the p-value is smaller than the threshold, e.g. 1%, 5% or 10%, then we reject the null hypothesis of equal averages.

引用

1

https://en.wikipedia.org/wiki/T-test#Independent_two-sample_t-test

2

https://en.wikipedia.org/wiki/Welch%27s_t-test