Skip to content

Instantly share code, notes, and snippets.

@alexbeutel
alexbeutel / gist:5359257
Created April 10, 2013 23:11
from stan lda example
data {
int<lower=2> K; // num topics
int<lower=2> V; // num words
int<lower=1> M; // num docs
int<lower=1> N; // total word instances
int<lower=1,upper=V> w[N]; // word n
int<lower=1,upper=M> doc[N]; // doc ID for word n
vector<lower=0>[K] alpha; // topic prior
vector<lower=0>[V] beta; // word prior
@alexbeutel
alexbeutel / gist:4153183
Created November 27, 2012 08:43
RTM Data Generator for WWW 2013
#!/usr/bin/env python
# encoding: utf-8
import sys
import os
def runProduct(fin,fout,generator,n):
for line in fin:
vals = line.split()
for term in generator:
@alexbeutel
alexbeutel / gist:4115039
Created November 20, 2012 00:06
RTM Data Generator Sparse
#!/usr/bin/env python
# encoding: utf-8
import sys
import os
def runProduct(fin,fout,generator,n):
for line in fin:
vals = line.split()
for term in generator:
<?php
$find = array("findWord1", "findWord2");
$replace = array("replaceWord1", "replaceWord2");
// wouldn't suggest keeping the file in the same directory as being search
// so make the line below a string of an absolute folder location
$home = getcwd();
$all = array();
function bfs($path) {
@alexbeutel
alexbeutel / gist:151142
Created July 21, 2009 05:34
Simple plotting in mathematica to demontrate wheel barrel effect
(*
Alex Beutel
July 23, 2009
Simple script to show wagon-wheel effect / stroboscopic effect
for a propeller in terms of the y coordinate vs. time and
radians vs. time. Graphs both with varying "frame-rates."
*)
f1[x_] := Cos[x];
f2[x_] := Cos[x + 2 \[Pi]/3];
f3[x_] := Cos[x + 4 \[Pi]/3];
/*
This method adds a new menu to the top menu bar
string title - The title of the menu
hrefs - array of strings that contains the URLs for the menu items
links - text to be displayed for the link. if you would like a menu seperator, pass '<hr>' as the string
*/
function buildAndInsertMenu(title, hrefs, links)
{
var cond = title.replace(" ", "_");
var menu = document.createElement('div');
#!/usr/bin/env python
# encoding: utf-8
import sys
import random
import os
def clearscreen(numlines=100):
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc
#!/usr/bin/env python
# encoding: utf-8
import sys
import random
import os
def clearscreen(numlines=100):
if os.name == "posix":
# Unix/Linux/MacOS/BSD/etc