Skip to content

Instantly share code, notes, and snippets.

View xiangze's full-sized avatar

xiangze xiangze

View GitHub Profile
@xiangze
xiangze / particlefilter_lorenz
Created September 6, 2012 17:29
particle filter expample using lorenz equation
#library(odesolve)
#source("lotz.f.noise.R")
lotz.params <- list(dl = 10,
bt = 8/3,
ro = 28)
lotz.noise <- function(t, y,v,p=lotz.params){
y <- y+rnorm(3,v)
dl <- p[['dl']]
ro <- p[['ro']]
library(animation)
#N <- 10
tmax <- 1e4
freq_ex <- tmax/100
theta <- 0.5
plotrange <- c(-1,1)
cols <- heat.colors(N)
@xiangze
xiangze / VCAsample.py
Last active December 20, 2018 10:11
Vanishing component analysis code in Python, using sympy
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 12 21:02:25 2014
@author: xiangze
"""
import numpy as np
from sympy import *
from scipy import linalg, mat, dot
@xiangze
xiangze / rjags_rossler.R
Last active December 24, 2015 04:29
parameter estimation of rossler equation by using rjags
library(rjags)
alpha<-1/10.
beta<-1/10.
c<-6
N <- 500
dt<-0.1
sig<-1e-4
itenum<-500000
library(rjags)
alpha<-1/10.
beta<-1/10.
c0<-6
N <- 500
dt<-0.1
sig<-1e-4
itenum<-200000
#library(parallel)
#THe model is from Stan User's Guide and Reference Manual
#https://github.com/stan-dev/stan/releases/download/v2.0.1/stan-reference-2.0.1.pdf
library(rstan)
model <- "
data {
int<lower=0> N; // number of data points
int<lower=1> D; // number of dimensions
int<lower=1> K; // number of clusters
D <- 2
tmax <- 100
dt <- 0.1
v <- 0.4
m <- 1
a <- c(1,1)
r <- 0.3
potential <- function(x){
library(rstan)
model <- "
data {
int<lower=2> K;
int<lower=0> N;
int<lower=1> D;
int<lower=1,upper=K> y[N];
@xiangze
xiangze / procedural_stancode.R
Created December 8, 2013 16:53
an example of procedural stan code (no practical meaning).
library(rstan)
model <- "
data {
int<lower=0> N; // number of data points
int<lower=1> D; // number of dimensions
real<lower=0,upper=1> param[D];
}
`define N (64)
`define N1 (63)
module SRM596_Div1(
input clk,
input rstn,
input [31:0] indata,
input wenable,
output reg [12:0] answer,
output reg ans_enable