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 matplotlib.pyplot as plt | |
import numpy as np | |
import tensorflow as tf | |
sentence = "Snoopy is a beagle" | |
tokens = sentence.split(" ") | |
print(tokens) |
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
def calc_prop_matching_pairs(trial_results): | |
num_matching_pairs = sum([1 for x in results.values() if x[0] == x[1]]) | |
num_total_pairs = len(results.values()) | |
# of all the pairs we have drawn, what proportion were matching pairs of socks? | |
prop_matching_pairs = num_matching_pairs / num_total_pairs | |
print(f"\nprop valid pairs over {NUM_TRIALS:,} trials: {prop_matching_pairs:.2f}") |
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
def draw_pairs(num_trials): | |
trial_results = {} | |
for trial_num in range(num_trials): | |
if trial_num % 10000 == 0: | |
print(f"running trial number: {trial_num}") | |
trial_results[trial_num+1] = np.random.choice(all_socks, 2, replace=False).tolist() | |
return trial_results |
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 numpy as np | |
np.random.seed(123) |
NewerOlder