Skip to content

Instantly share code, notes, and snippets.

@eustin
Created May 15, 2023 22:55
Show Gist options
  • Save eustin/972049a1ff2bb807c5cf6e194d965693 to your computer and use it in GitHub Desktop.
Save eustin/972049a1ff2bb807c5cf6e194d965693 to your computer and use it in GitHub Desktop.
stat_sig_random_15
@njit(parallel=True)
def sample_diffs_in_rates(all_users, num_control_users, num_simulations):
results = np.zeros(num_simulations)
for i in prange(num_simulations):
# numpy random shuffling appears to be slower when using numba
random.shuffle(all_users)
control_rate = all_users[:num_control_users].mean()
# we assume the rest of the users are variant users
variant_rate = all_users[num_control_users:].mean()
results[i] = variant_rate - control_rate
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment