def test_t_ind(): "Test independent samples t-test" ds = datasets.get_uts(True) y = ds.eval("utsnd.x") n_cases = len(y) n = n_cases / 2 t = stats.t_ind(y, n, n) p = stats.ttest_p(t, n_cases - 2) t_sp, p_sp = scipy.stats.ttest_ind(y[:n], y[n:]) assert_equal(t, t_sp) assert_equal(p, p_sp) assert_allclose(stats.ttest_t(p, n_cases - 2), np.abs(t)) # permutation y_perm = np.empty_like(y) for perm in permute_order(n_cases, 2): stats.t_ind(y, n, n, out=t, perm=perm) y_perm[perm] = y t_sp, _ = scipy.stats.ttest_ind(y_perm[:n], y_perm[n:]) assert_allclose(t, t_sp)