Skip to content

Instantly share code, notes, and snippets.

View twiecki's full-sized avatar

Thomas Wiecki twiecki

View GitHub Profile
@twiecki
twiecki / example_breaks_map.py
Created June 24, 2011 17:53
Example code that shows how MAP can be broken when fmin walks outside the support of the variables.
import pymc as pm
t = pm.Uniform('t', 0, 1, verbose=1)
y = pm.Normal('x', mu=t, tau=1, value=-5, observed=True)
pm.MAP([t,y]).fit(verbose=1)
@twiecki
twiecki / sim_drift_gpu.py
Created December 9, 2011 16:23
Simulating drift-processes on the GPU using PyCuda
from __future__ import division
import pycuda.compiler
import pycuda.gpuarray as gpuarray
import pycuda.autoinit
import pycuda.curandom
from pycuda.cumath import exp as pycuda_exp
from pycuda.compiler import SourceModule
import matplotlib.pyplot as plt
from kabuki.utils import scipy_stochastic
@twiecki
twiecki / test_proto.py
Created February 6, 2012 23:17
PrototypedFrom of a list
from traits.api import \
PrototypedFrom, Float, HasTraits, Instance, Str, List, on_trait_change
from copy import copy
class Parent (HasTraits):
first_name = Str
family_name = ''
favorite_first_name = Str
child_allowance = Float(1.00)
@twiecki
twiecki / fastdm_cdf.pyx
Created March 12, 2012 12:48 — forked from anonymous/fastdm_cdf.pyx
function for censored distrbutions
#!/usr/bin/python
# Cython wrapper for the fast-dm code by Voss & Voss
# (C) by Thomas Wiecki (thomas_wiecki@brown.edu), 2010
# GPLv2 or later.
from __future__ import division
import numpy as np
cimport numpy as np
cimport cython
@twiecki
twiecki / simplegibbs_cython.pyx
Created May 11, 2012 18:55 — forked from fonnesbeck/simplegibbs_cython.pyx
Simple Gibbs sampler in cython, adapted from http://bit.ly/J3vP63
'''
Gibbs sampler for function:
f(x,y) = x x^2 \exp(-xy^2 - y^2 + 2y - 4x)
using conditional distributions:
x|y \sim Gamma(3, y^2 +4)
y|x \sim Normal(\frac{1}{1+x}, \frac{1}{2(1+x)})
'''
@twiecki
twiecki / SimonRegressors
Created August 22, 2012 17:31
ipython notebook for eyetracking data
{
"metadata": {
"name": "SimonPupilRegression"
},
"nbformat": 3,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
@twiecki
twiecki / pydata12_zipline_twiecki.ipynb
Created October 27, 2012 03:33
IPython notebook used in my PyData NYC'12 presentation.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@twiecki
twiecki / ipcluster.py
Created December 10, 2012 17:03
Relevant changes to starcluster ipcluster.py code to start multiple ipython nbs on multiple ports
def _start_notebook(self, master, user, profile_dir, profile_name='default', notebook_port=8888):
master.ssh.execute('ipython profile create %s' % profile_name)
log.info("Setting up IPython web notebook for user: %s" % user)
user_cert = posixpath.join(profile_dir, '%s.pem' % user)
ssl_cert = posixpath.join(profile_dir, '%s.pem' % user)
if not master.ssh.isfile(user_cert):
log.info("Creating SSL certificate for user %s" % user)
ssl_subj = "/C=US/ST=SC/L=STAR/O=Dis/CN=%s" % master.dns_name
master.ssh.execute(
"openssl req -new -newkey rsa:4096 -days 365 "
@twiecki
twiecki / ipynb_boston_python.ipynb
Created January 25, 2013 02:01
IPython notebook used during the Boston Python Meetup.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.