Skip to content

Instantly share code, notes, and snippets.

View galenseilis's full-sized avatar
📈
f(data | model, expertise) = insight

Galen Seilis galenseilis

📈
f(data | model, expertise) = insight
View GitHub Profile
import numpy as np
from scipy.stats import t
import statsmodels.api as sm
np.random.seed(2022)
# Prepare data
N = 51
k = 1
x = np.random.normal(size=N)
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import binom
n, p = 100, 0.5
x = np.arange(n)
fig, ax = plt.subplots(1, 1)
ax.plot(x, binom.pmf(x, n, p), 'bo', ms=1, label='binom pmf')
ax.vlines(x, 0, binom.pmf(x, n, p), colors='b', lw=1, alpha=0.5)
from scipy.stats import beta
import matplotlib.pyplot as plt
import numpy as np
a, b = 0.99, 0.5
fig, ax = plt.subplots(1, 1)
x = np.linspace(0, 1, 10000)
y = beta.pdf(x, a, b)
from scipy.stats import beta
import matplotlib.pyplot as plt
import numpy as np
params = [[81, 219],
[82, 219],
[81+100, 219+200]]
for a, b in params:
from scipy.stats import beta
import matplotlib.pyplot as plt
import numpy as np
params = (((8,2), (5,5), (2,8)), ((2,1), (1,1), (1,2)), ((0.8,0.2), (0.5,0.5), (0.2,0.8)))
title_suffixes = ('Bell-shape', 'Straight lines', 'U-shape')
colors = ('blue', 'yellow', 'red')
x = np.linspace(0, 1, 10000)
import matplotlib.pyplot as plt
import numpy as np
from mpmath import *
mp.pretty = True
nseq = range(1, 10001)
hseq = []
for i in nseq:
mp.dps = i
x, fx = np.unique(list(str(pi).replace('.', '')), return_counts=True)
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import numpy as np
gs = gridspec.GridSpec(4, 4)
x = np.random.randint(1,7,size=10**5)
n, c = np.unique(x, return_counts=True)
ax1 = plt.subplot(gs[:2, :2])
ax1.bar(n, c)
import os.path as path
from tempfile import mkdtemp
import numpy as np
m = 10**6
n = 10**3
filename = path.join(mkdtemp(), 'X.dat')
X = np.memmap(filename, dtype='float32', mode='w+', shape=(m, n))
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.stats import shapiro, probplot
import statsmodels.api as sm
data = sm.datasets.scotland.load()
data.exog = sm.add_constant(data.exog)
links = [sm.families.Gaussian(), sm.families.Gamma()]
import numpy as np
n = 10
m = 50
s = 100
y = np.mean(np.random.normal(m, s, n * 10**4).reshape(10**4, n), axis=1)
print(np.std(y, ddof=1), s / np.sqrt(n))