Skip to content

Instantly share code, notes, and snippets.

View albertyumol's full-sized avatar
:octocat:
just bash-ing around

Albert 'Bash' Yumol albertyumol

:octocat:
just bash-ing around
  • Manila, Philippines
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@albertyumol
albertyumol / confidence_intervals.ipynb
Created October 25, 2019 01:25
Sample problem for demonstrating confidence intervals in Python.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@albertyumol
albertyumol / hypothesys_testing.ipynb
Created October 25, 2019 01:22
Saple problem for hypothesis testing in Python.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@albertyumol
albertyumol / normal.py
Created October 25, 2019 01:06
Plotting normal pdf's in Python.
import numpy as np
import matplotlib.pyplot as plt
def normal_pdf(x, mu=0, sigma=1):
sqrt_two_pi = np.sqrt(2*np.pi)
return (np.exp(-(x-mu)**2/2/sigma**2)/(sqrt_two_pi*sigma))
xs = [x / 10.0 for x in range(-50, 50)]
plt.plot(xs, [normal_pdf(x, sigma=1) for x in xs], '-', label='$\mu=0$, $\sigma=1$')
plt.plot(xs, [normal_pdf(x, sigma=2) for x in xs], '--', label='$\mu=0$, $\sigma=2$')
plt.plot(xs, [normal_pdf(x, sigma=0.5) for x in xs], ':', label='$\mu=0$, $\sigma=0.5$')
@albertyumol
albertyumol / boy_or_girl.py
Created October 24, 2019 05:47
Calculating conditional probabilities in Python.
import random
def random_kid():
return random.choice(['boy','girl'])
both_girls = 0
older_girl = 0
either_girl = 0
random.seed(7)
for i in range(1000000):
@albertyumol
albertyumol / correlation.py
Created October 23, 2019 06:59
Calculate the correlation in Python.
#Provided that x and y have the same length.
import numpy as np
def standard_deviation(x):
x_bar = np.mean(x)
N = len(x)
deviation_mean = [x_i - x_bar for x_i in x]
return np.sqrt(np.dot(deviation_mean, deviation_mean) / N)
def covariance(x, y):
N = len(x)
@albertyumol
albertyumol / covariance.py
Created October 23, 2019 06:53
Calculate the covariance in Python.
#Provided that x and y have the same length.
import numpy as np
def covariance(x, y):
N = len(x)
x_bar = np.mean(x)
y_bar = np.mean(y)
deviation_mean_x = [x_i - x_bar for x_i in x]
deviation_mean_y = [y_i - y_bar for y_i in y]
return np.dot(deviation_mean_x, deviation_mean_y) / N