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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
NewerOlder