Skip to content

Instantly share code, notes, and snippets.

View trappmartin's full-sized avatar
🧗

Martin Trapp trappmartin

🧗
View GitHub Profile
@trappmartin
trappmartin / .bashrc
Last active December 1, 2017 14:37
.bashrc config
#!/bin/bash
#######################################################
# EXPORTS
#######################################################
# Expand the history size
export HISTFILESIZE=10000
export HISTSIZE=500
# Set the default editor
@trappmartin
trappmartin / vimrc
Last active July 17, 2018 16:56
.vimrc
set nocompatible
color pablo
syntax on
set number
set backspace=indent,eol,start
" highlight found words
set hlsearch
" show matching parenthesis
@trappmartin
trappmartin / gist:84ca6efbb8f47a6a36545da51894190c
Last active August 11, 2018 12:55
Change Julia 0.6 function syntax to Julia 1.0 using vim
%s/\({.*}\)\(([^)]*)\)\(\s=\)/\2 where \1\3/g
using Turing, Turing.RandomMeasures
@model dpmixture(x) = begin
rpm = DirichletProcess(1.0)
n = zeros(Int, length(x))
z = zeros(Int, length(x))
for i in eachindex(x)
z[i] ~ ChineseRestaurantProcess(rpm, n)
n[z[i]] += 1
using Turing
using Optim
using UnicodePlots
import StatsBase.mode
@model gdemo_d() = begin
s ~ InverseGamma(2, 3)
m ~ Normal(0, sqrt(s))
1.5 ~ Normal(m, sqrt(s))
2.0 ~ Normal(m, sqrt(s))
using DrWatson
@quickactivate "DynamicPPL_NeurIPS"
using Turing
using LinearAlgebra
using Random: seed!
seed!(1)
@model testmodel(p, O) = begin
x ~ Categorical(p)
using Turing
using Bijectors
using LinearAlgebra
Bijectors.bijector(d::LKJ) = PDBijector()
@model function correlation(y)
N,D = size(y)
mu ~ filldist(truncated(Normal(0, 100), -10, 10), D)
using Turing
@model function ibp(y, α, kmax, ::Type{MV}=Vector{Float64}) where {MV}
N = length(y)
ks = tzeros(Int, N)
ks[1] ~ Poisson(α)
ks[1] = ks[1] <= kmax ? ks[1] : kmax
z = tzeros(Int, N, kmax)
using Turing
# This is a crappy implementation of Isabel's model.
# For simplicity, I assume all data to be positiv-real valued.
# Isabel's paper: http://proceedings.mlr.press/v70/valera17a/valera17a.pdf
@model function adst(y, ::Type{TV}=Vector{Float64}) where {TV}
N,D = size(y)
@trappmartin
trappmartin / imm.jl
Last active August 28, 2020 17:02
infinite mixture model in Turing
using Turing
using Turing.RandomMeasures
# Implementation of infinite mixture model
@model function imm(y, α, ::Type{T}=Vector{Float64}) where {T}
N = length(y)
nk = tzeros(Int, N)
z = tzeros(Int, N)
for i in 1:N