Skip to content

Instantly share code, notes, and snippets.

View xiangze's full-sized avatar

xiangze xiangze

View GitHub Profile
library(tm)
library(Snowball)
gencorpus <- function(dat,stemn=T){
corpus <- Corpus(DataframeSource(data.frame(as.character(dat[,1]))))
corpus <- tm_map(corpus, removePunctuation)
corpus <- tm_map(corpus, tolower)
corpus <- tm_map(corpus, stripWhitespace)
corpus <- tm_map(corpus, function(x) removeWords(x,stopwords("english")))
if(stemn==T){
@xiangze
xiangze / clusterexample.R
Created November 1, 2014 01:31
various cluster method examples
N <- 10
k <- 3
#data
x0 <-0
x1 <-10
y0 <-0
y1 <-10
v2 <- 1
@xiangze
xiangze / STB.R
Last active March 3, 2023 07:57
Stick breaking process in stan
#from BUGS book page 293
#Stick-breaking process
#http://www2.imm.dtu.dk/courses/02443/projects/Roeder_JASA_1990.pdf
library(rstan)
C <- 10
data <-read.csv("data.csv")
N <-nrow(data)
model <-stan_model("STB.stan")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@xiangze
xiangze / HMC.py
Last active August 29, 2015 14:02
Hamilton Monte-Carlo with GMM in python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
#http://d.hatena.ne.jp/teramonagi/20120930/1348982608
#https://gist.github.com/teramonagi/3805923#file-mcmc_replica_exchange_mcmc-py
import repMC as repMC
@xiangze
xiangze / HMC_Theano.ipynb
Created June 19, 2014 13:26
Hamilton Monte-Carlo by Theano
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@xiangze
xiangze / ParticleFilter.py
Last active August 29, 2015 14:02
ParticleFilter which can be input arbitrary ODE(dynamical system)
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 14 18:48:17 2014
@author: xiangze
"""
import numpy as np
#from itertools import accumulate
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 07 20:38:05 2014
@author: xiangze
"""
from BeautifulSoup import BeautifulSoup
import urllib2
import time
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.