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
### compute pairwise distnances | |
from sklearn.metrics.pairwise import haversine_distances | |
import numpy as np | |
#here we make up a bunch of random coordinates | |
lats = np.random.uniform(45,47,size=(100,)) | |
longs = np.random.uniform(-120,-100,size=(100,)) | |
coords = list(zip(lats, longs)) |
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 | |
def return_linear_pdf(n): | |
#n is the number of dimensions/players in the joint action | |
#this describes a n-dimensional linear surface defined from [0,1] that integrates to 1 | |
P = lambda x: (2.0/float(n))*np.sum(x) | |
return(P) | |
def return_linear_cdf(n): | |
#cummulative distribution function for linear PDF |
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 datetime import datetime as dt | |
import calendar | |
import numpy as np | |
def num_to_circle(z): | |
#this functions accepts a number between 0 and 1 and projects it onto x, y coordinates on the unit circle | |
x = np.cos(2*np.pi*z) | |
y = np.sin(2*np.pi*z) | |
return((x, y)) | |
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 tkinter as tk | |
flag = False # Global flag | |
idx = 0 # loop index | |
def switch(): | |
"""Enable scanning by setting the global flag to True.""" | |
global flag | |
flag = True |
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
#cells will fill entire width of the browser | |
from IPython.display import display, HTML | |
display(HTML(data=""" | |
<style> | |
div#notebook-container { width: 95%; } | |
div#menubar-container { width: 65%; } | |
div#maintoolbar-container { width: 99%; } | |
</style> | |
""")) |
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 copy | |
import random | |
global market_ref | |
market_ref = {'item_1': 100.0, | |
'item_2': 200.0, | |
'item_3': 100.0} | |
def market_shift(): | |
#updates the global market baseline |
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 read_matlab_float(strin): | |
strin = strin.strip() | |
tokens = strin.split("e") | |
sign_ = tokens[1][0] | |
if sign_ == "-": | |
sign = -1.0 | |
else: | |
sign = 1.0 | |
p = float(tokens[1][1:].strip()) | |
mant = float(tokens[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
#Requires google application password generation if using 2-factor authentication | |
#https://support.google.com/accounts/answer/185833?hl=en | |
#Update credential storage method in __init__ method | |
#Example usage: | |
""" | |
from send_notif_email import * | |
try: |
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
#Example usage | |
""" | |
upleft = [47.6197793,-122.3592749] Upper left coordinate of map image | |
bttmright = [47.607274, -122.334786] Lower right coordinate of map image | |
imgsize = [1135,864] Pixel size of map image | |
mp = MapOverlay(upleft, bttmright, imgsize) | |
#then given a list of latitude/longitude pairs , we can get their relative positions on the image of the map, note | |
#that image pixel positions start with (0,0) at the top left of the image, so plotting will require inverting the y-axis |