Skip to content

Instantly share code, notes, and snippets.

@boscacci
Last active December 1, 2023 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boscacci/2a1a88479cf06f228a2303f8dcd336a9 to your computer and use it in GitHub Desktop.
Save boscacci/2a1a88479cf06f228a2303f8dcd336a9 to your computer and use it in GitHub Desktop.
Welch's Unequal Variances T-test
def twosample_tstat_welch(experimental, control):
"""
Runs Welch's unequal variances t-test
Accepts 2 pandas series or numpy arrays
Returns a t-stat
"""
xbar_1 = experimental.mean()
xbar_2 = control.mean()
var_1 = experimental.var()
var_2 = control.var()
n1, n2 = len(experimental), len(control)
num = xbar_1 - xbar_2
denom = sqrt((var_1/n1) + (var_2/n2))
return num/denom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment