This file contains hidden or 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
#Another plotting library, a little fancier than matplotlib | |
import seaborn as sns | |
#Another distribution of carrot lengths | |
#(The 'scale' is the standard deviation parameter) | |
virginias_vegetables = np.random.normal(loc = mu, scale = 3, size = n) | |
#A third distribution of carrot lengths | |
raouls_roots = np.random.normal(loc = mu, scale = 5, size = n) |
This file contains hidden or 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
#Function to calculate variance | |
def find_var(X): | |
mu = X.mean() | |
n = len(X) | |
variance = np.sum( | |
(X - mu)**2 | |
) / n | |
This file contains hidden or 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
#Function to calculate standard deviation | |
def find_std(X): | |
mu = X.mean() | |
n = len(X) | |
sigma = np.sqrt( | |
np.sum( | |
(X - mu)**2 | |
) / n |
This file contains hidden or 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
#Mean: carrot length in cm | |
mu = 20 | |
#Size of population: number of carrots in market | |
n = 1000 | |
# Random variable, normally-distributed: carrot length | |
import numpy as np | |
carrot_lengths = np.random.normal(loc = mu, size = n) |
This file contains hidden or 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 pandas as pd | |
#Toy data: brightness of color of each carrot from Fancy Farms. | |
#(Ideal brightness is at the mean.) | |
brightness = (carrot_lengths / (5 + np.random.random(1000))) | |
#Extra toy data from the farm: dampness of the soil from which the | |
#carrot was pulled. 50 is normal dampness; 100 is sodden; 0 is dry. | |
dampness = np.random.normal(loc = 50, scale = 25, size = n) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder