Created
September 27, 2021 12:31
-
-
Save liudong/2933622dba9018eb11cf1a5cc2110f7e to your computer and use it in GitHub Desktop.
Python: t-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import stats | |
differences = [B[i] - A[i] for i in range(len(A))] | |
# one sample t-test | |
stats.ttest_1samp(differences, popmean=0) | |
# assess the equality of variances | |
stats.levene(A, B) | |
# independent t-test | |
stats.ttest_ind(A, B, equal_var=True) | |
# t-test on TWO RELATED samples | |
stats.ttest_rel(A, B) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment