Skip to content

Instantly share code, notes, and snippets.

View ssophwang's full-sized avatar

Sophia ssophwang

View GitHub Profile
@ssophwang
ssophwang / lines.py
Created September 23, 2017 14:57
lines.py
from scene import *
import ui
import random
import numpy as np
import speech
import time
def gradient_descent_line_fitter(x, y, learning_rate = 0.02, stop_criteria = 1e-5, max_iter = 10000):
scaling_factor = 100.0
x = x/scaling_factor
@ssophwang
ssophwang / lines.py
Created September 16, 2017 15:08
lines.py
from scene import *
import ui
import random
import numpy as np
import speech
import time
def gradient_descent_line_fitter(x, y, learning_rate = 0.02, stop_criteria = 1e-5, max_iter = 10000):
scaling_factor = 100.0
x = x/scaling_factor
@ssophwang
ssophwang / lines.py
Created August 12, 2017 14:04
lines.py
from scene import *
import ui
import random
import numpy as np
import speech
import time
# Create data
N = 1000
a = 3.5
@ssophwang
ssophwang / lines.py
Created August 5, 2017 14:02
lines.py
from scene import *
import ui
class MyScene (Scene):
def setup(self):
self.background_color = 'midnightblue'
self.points = []
self.point_size = 10
def touch_began(self, touch):
@ssophwang
ssophwang / Rabbit_Robber.py
Created June 10, 2017 18:51
Rabbit_Robber.py
import ui
import speech
import random
from PIL import Image
import numpy
rabbit_size = 50
v = ui.View(background_color=('#bcdeff'))
board = ui.View()
v.add_subview(board)
@ssophwang
ssophwang / Rabbit_Robber.py
Created June 3, 2017 14:12
Rabbit_Robber.py
import ui
import speech
import random
from PIL import Image
rabbit_size = 50
v = ui.View(background_color=('#bcdeff'))
board = ui.View()
v.add_subview(board)
v.present('full_screen', hide_title_bar=False , orientations=['landscape'])
@ssophwang
ssophwang / Rabbit_Robber.py
Created May 13, 2017 15:21
Rabbit_Robber.py
import ui
import random
from PIL import Image
rabbit_size = 100
v = ui.View(background_color=('#bcdeff'))
board = ui.View()
v.add_subview(board)
v.present('full_screen', hide_title_bar=False , orientations=['landscape'])
board.frame = (v.width-v.height, rabbit_size/2, v.height-rabbit_size, v.height-rabbit_size)
@ssophwang
ssophwang / Rabbit_Robber.py
Created May 13, 2017 14:09
Rabbit_Robber.py
import ui
import random
from PIL import Image
v = ui.View(background_color=('#bcdeff'))
board = ui.View()
v.add_subview(board)
v.present('full_screen', hide_title_bar=False , orientations=['landscape'])
board.frame = (v.width-v.height, 0, v.height, v.height)
{"bagpipe": {"on": 0.07142857142857142, "said": 0.07142857142857142, "Shall": 0.07142857142857142, "Did": 0.07142857142857142, "Ah": 0.07142857142857142, "didn": 0.35714285714285715, "I": 0.07142857142857142, "won": 0.07142857142857142, "lying": 0.07142857142857142, "if": 0.07142857142857142}, "pardon": {"the": 1.0}, "Gnu": {"murnood": 1.0}, "Night": {"s": 0.6666666666666666, "\n": 0.3333333333333333}, "yellow": {"caterpillar": 1.0}, "four": {"nickels": 0.2, "\n": 0.4, "is": 0.2, "more": 0.2}, "hath": {"spoken": 0.3333333333333333, "sent": 0.3333333333333333, "lent": 0.3333333333333333}, "Wretch": {"I": 1.0}, "sleep": {"late": 0.2, "\n": 0.6, "in": 0.2}, "SARDINES": {"\n": 1.0}, "Zoomed": {"up": 1.0}, "evermore": {"\n": 1.0}, "hate": {"\n": 1.0}, "Until": {"I": 0.3333333333333333, "a": 0.3333333333333333, "he": 0.3333333333333333}, "drinkin": {"that": 1.0}, "whose": {"foot": 0.3333333333333333, "velvet": 0.3333333333333333, "fiery": 0.3333333333333333}, "swam": {"away": 1.0}, "Claus": {"\n": 1.0}, "sweetest":
import re, random
import numpy as np
import json
poem_files = ['pg17192.txt', 'Where the Sidewalk Ends by Shel Silverstein_djvu.txt']
poem_lines = []
firstword_count_dict = {}
firstword_prob_dict = {}
for poem_file in poem_files:
f = open(poem_file, 'r')