Skip to content

Instantly share code, notes, and snippets.

@ajschumacher
Created July 18, 2023 18:40
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 ajschumacher/b781599169ed8a5ab34bde9b1115c875 to your computer and use it in GitHub Desktop.
Save ajschumacher/b781599169ed8a5ab34bde9b1115c875 to your computer and use it in GitHub Desktop.
public snippets

chi-squared test

import scipy.stats

obs = np.array([[a, b],
                [c, d]])
_, p, _, _ = scipy.stats.chi2_contingency(obs)

plt.savefig("clarity.png", dpi=240, bbox_inches="tight", facecolor="white")

with plt.style.context('seaborn'):
    # plotting code here...
# or just globally:
plt.style.use('seaborn')

import matplotlib.ticker
plt.gca().yaxis.set_major_formatter(matplotlib.ticker.PercentFormatter(decimals=0))
plt.gca().xaxis.set_major_formatter(matplotlib.ticker.PercentFormatter(decimals=0))

Evan's simple sample size tool: https://www.evanmiller.org/ab-testing/sample-size.html


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment