Skip to content

Instantly share code, notes, and snippets.

View Smerity's full-sized avatar

Stephen Merity Smerity

View GitHub Profile
@Smerity
Smerity / fib.R
Last active August 29, 2015 13:56
Fib in C, Python, PyPy, R, and R (JIT)
require(compiler)
enableJIT(3)
fib = function(x) {
if (x < 2) {
return(x)
}
return(fib(x - 1) + fib(x - 2))
}
@Smerity
Smerity / Error from Makefile
Last active August 29, 2015 13:56
"Special" error in C++
smerity@pegasus:~/cs207$ make viewer
/usr/bin/g++ -std=gnu++0x -fopenmp -funroll-loops -O3 -W -Wall -Wextra -Wfatal-errors -I. -MD -MF .deps/viewer.d -c -o viewer.o viewer.cpp
viewer.cpp:70:1: error: expected ‘}’ at end of input
compilation terminated due to -Wfatal-errors.
make: *** [viewer.o] Error 1
@Smerity
Smerity / Lec7.py
Created February 24, 2014 22:38
Rage inducing code snippets from lectures and homework
# How many of these lines actually do something?
if (U < A):
x[i] = x_star
i = i + 1
x_prev = x_star
else:
x[i] = x_prev
x_prev = x[i]
i = i + 1
i=i-1
@Smerity
Smerity / mvslice_broken.py
Created March 12, 2014 01:42
Issue with sampling uniform for mvslice
def mvslice(pdf, x0, widths, sampleSize=1000, dims=2, burnin=0, thin=0):
"""
:param pdf: function we're trying to sample
:param x0: inital point
:param widths: prior for widths of our hyperrectangle
:param sampleSize: number of samples to generate
:param dims: dimension of our multivariate space
:param burnin: number of samples to get rid of at beginning
:param thin: number of samples to keep
"""
@Smerity
Smerity / gist:9646766
Created March 19, 2014 17:24
Our score according to Nate's predictions
Marking temp/nate_checker.csv against temp/final.csv
Error for match Albany NY vs Mt St Mary's (S_507_686) = -2.88785816957
Error for match American Univ vs Arizona (S_509_511) = -0.0204754420265
Error for match Arizona vs Wisconsin (S_511_849) = -2.46652362788
Error for match Arizona St vs Colorado (S_512_556) = -1.80260502788
Error for match Arizona St vs Gonzaga (S_512_607) = -4.27299389895
Error for match Arizona St vs Massachusetts (S_512_663) = -1.46103546276
Error for match Arizona St vs Michigan (S_512_670) = -3.99960393573
Error for match Arizona St vs St Louis (S_512_780) = -2.09220210929
Error for match Arizona St vs Texas (S_512_793) = -3.61348661457
@Smerity
Smerity / am207_hw6.ipynb
Created March 27, 2014 03:59
AM207: HW#6 and Project Proposal
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Smerity
Smerity / AM207_StephenMerity_HM7.ipynb
Created April 3, 2014 03:46
AM207 HW#7: Genetic Algorithms and Gradient Descent
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Smerity
Smerity / bad_rpc.go
Created April 7, 2014 20:36
Go hangs when encountering a type it doesn't know how to handle during RPC + deserialization
package main
import (
"encoding/gob"
"fmt"
"log"
"net"
"net/rpc"
)
@Smerity
Smerity / AM207_StephenMerity_HM6.ipynb
Created April 10, 2014 16:21
AM207 Project Proposal
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Smerity
Smerity / fastest.results
Created April 27, 2014 03:48
Increasing PyPy's performance on Minilight by cProfile
smerity@pegasus:~/Coding/montelight/python$ time ~/Coding/Reference/pypy-2.2.1-linux64/bin/pypy -m cProfile minilight.py roomfront-n-1000.ml.txt
MiniLight 1.6 Python - http://www.hxa.name/minilight
iteration: 3^C
interrupted
1155613811 function calls (1062023566 primitive calls) in 89.591 seconds
Ordered by: standard name