Skip to content

Instantly share code, notes, and snippets.

View twiecki's full-sized avatar

Thomas Wiecki twiecki

View GitHub Profile
@twiecki
twiecki / ppc.ipynb
Last active August 29, 2015 14:25
Example NB to run a PPC test using new random() methods.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@twiecki
twiecki / table.html
Last active September 15, 2015 14:07
<html>
<table id="comparetable" class="clean">
<tr>
<td class="blank"> </td>
<th>Machine Learning</th>
<th>Frequentist<br>Statistics</th>
<th>Probabilistic<br>Programming</th>
</tr>
<tr>
<td class="rowTitle">Prediction</td>
@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 / 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 / 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 "
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.