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 | |
| # From https://www.notion.so/977d5e5be0434bf996704ec361ad621d?v=fe54f89ca9e04ac799af42b39e1efc4b | |
| path = "COVID 19 Containment measures data.csv" | |
| df = pd.read_csv(path) | |
| withoutUS = df[~df["Country"].str.contains("US:")] | |
| withoutUS = withoutUS[~withoutUS["Country"].str.contains("United States")] | |
| numCountries = withoutUS.Country.unique().shape[0] |
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 math | |
| import scipy.stats as st | |
| # assumes bivariate normal, dichotomised groups | |
| def dichotomy_r_to_d(r) : | |
| d = 2*r / (math.sqrt(1 - r**2)) | |
| return d | |
| # Equation 9 | |
| # https://sci-hub.tw/10.1037/1082-989X.11.4.386 |
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
| from scipy.spatial.distance import cdist | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| # First write a covariance function. e.g. rbf | |
| def radial_basis_kernel(x1, x2, varSigma, lengthScale): | |
| if x2 is None: | |
| d = cdist(x1, x1) | |
| else: | |
| d = cdist(x1, x2) |
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 | |
| probability = 1/10000 | |
| wealth = 120000 | |
| houseValue = 100000 | |
| bound = probability * np.log(wealth - houseValue) \ | |
| + (1 - probability) * np.log(wealth) | |
| maxPremium = wealth - np.exp(bound) |
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
| # https://help.open.ac.uk/documents/policies/working-out-your-class-of-honours/files/50/honours-class-working-out.pdf | |
| # Only 2nd and 3rd year courses count. | |
| # Course, credits, grade, year | |
| courses = [ | |
| ["M343", 30, "Distinction", 3], | |
| ["M249", 30, "Distinction", 2], | |
| ["M248", 30, "Distinction", 2], | |
| ["MST210", 60, "Grade 2 Pass", 2] | |
| ] |
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
| ################################## | |
| ## DAY 1 | |
| # Evaluate 1 + 1 and then 1 + "one". Is Io strongly typed or weakly typed? | |
| 1 + 1 | |
| 1+"one" | |
| # > Exception: argument 0 to method '+' must be a Number, not a 'Sequence' | |
| # Io is Strong: it does not perform implicit casts between types. |
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
| # Every thing is an object. | |
| # Every interaction with an object is a message. | |
| # You don’t instantiate classes; you clone other objects called prototypes. | |
| # Objects remember their prototypes. | |
| # Objects have slots. Slots contain objects, including method objects. | |
| # A message returns the value in a slot or invokes the method in a slot. | |
| # If an object can’t respond to a message, it sends that message to its prototype. | |
| Vehicle := Object clone | |
| Vehicle description := "Something to take you places" |
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
| gdp = 80683787e6 # in 2017: https://data.worldbank.org/indicator/NY.GDP.MKTP.CD | |
| population = 7.6e9 # http://www.worldometers.info/world-population/ | |
| perCap = gdp / population | |
| # >>> $10616 | |
| # Sanity check: the World Bank estimate, 10714, is very close. | |
| # https://data.worldbank.org/indicator/NY.GDP.PCAP.CD | |
| # Subtract depreciation |
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
| #!/usr/bin/env python3 | |
| from pandas import DataFrame | |
| import seaborn as sns | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| #%% | |
| # Figures are not time-consistent: they each represent a point between 2010 - 2016 |
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
| sys.setrecursionlimit(500) | |
| from ai_safety_gridworlds.environments.shared.safety_game import Actions | |
| from ai_safety_gridworlds.environments.shared.rl.environment import TimeStep | |
| from hashlib import sha1 | |
| import numpy | |
| import copy | |
| ACTIONS = [ a for a in Actions if a is not Actions.QUIT ] |