This file contains 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 value_iteration_A(probs, gamma, rewards, oldV): | |
newV = oldV.copy() | |
nstates, nactions = probs.shape[0], probs.shape[-1] | |
for s in range(nstates): | |
weightedV = np.zeros([nactions], dtype='float64') | |
for a in range(nactions): | |
weightedV[a] = np.dot(probs[s,:,a], oldV) | |
newV[s] = rewards[s] + gamma * weightedV.max() | |
return newV | |
This file contains 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
# Created from these lecture notes: | |
# http://cseweb.ucsd.edu/classes/wi13/cse150-a/lecture/lecture11.pdf | |
# http://cseweb.ucsd.edu/classes/wi13/cse150-a/lecture/lecture12.pdf | |
# http://cseweb.ucsd.edu/classes/wi13/cse150-a/lecture/lecture13.pdf | |
# Dependencies: | |
# init_{a,b,pi} := the initial estimated matrices, can be random | |
# compute_forward := calculates the alpha matrix | |
# compute_reverse := calculates the beta matrix | |
# compute := calculates each of the matrices for the E-step |
This file contains 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
// this first version uses a function callback to pass in the object reference... | |
for (var i = 0; i < files.length; i++) { // WORKS | |
var setFile = function(file) { | |
return function(err, data) { | |
if (err) throw err; | |
file[1] = data; | |
}; | |
}; | |
fs.readFile(files[i][2], 'utf8', setFile(files[i])); |
This file contains 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
Movable.prototype.doICollide = function(collidables) { | |
var myPosition = this.position; | |
var myNewPos = this.position.clone().add(this.velocity); | |
// check if i collide with anything! | |
for (var id in collidables) { | |
if (collision(myPosition, myNewPos, collidables[id])) { | |
return true; | |
} | |
} |
This file contains 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
# collision.py | |
# needed for python 2.x | |
from __future__ import division | |
# permutation | |
def perm(x, n): | |
"x balls in n buckets" | |
def mult_l(acc, head): | |
return acc * head |
This file contains 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 python | |
# find_dup_files.py | |
# Trevor Pottinger | |
# Sun Nov 10 21:55:45 PST 2013 | |
import hashlib | |
import sys | |
import os | |
from os.path import join, getsize |
This file contains 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
# nhands.py | |
# Trevor Pottinger | |
# Fri Mar 14 22:23:19 PDT 2014 | |
from random import random | |
def counts2deck(ccounts): | |
"""Converts the card counts to a list of sorted cards""" | |
deck = [] | |
for letter in ccounts: |
This file contains 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
# vidcopy.py | |
# Trevor Pottinger | |
# Thu Mar 6 17:18:22 PST 2014 | |
import numpy as np | |
# lets try reading in a file and then writing it out | |
from moviepy.video.io.ffmpeg_reader import FFMPEG_VideoReader as reader | |
from moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter as writer |
This file contains 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
# nhands.py | |
# Trevor Pottinger | |
# Fri Mar 14 22:23:19 PDT 2014 | |
import time | |
from random import random | |
def my_cmp(x,y): | |
if x[1] > y[1]: | |
return -1 |
This file contains 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
// self_parsing.go | |
// Mon May 26 09:47:10 PDT 2014 | |
package main | |
import ( | |
"os" | |
"fmt" | |
"reflect" | |
"go/ast" |
OlderNewer