Skip to content

Instantly share code, notes, and snippets.

Martin Trapp trappmartin

View GitHub Profile
View adst.jl
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)
View Ibn_paper.jl
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)
View lkj_turing_example.jl
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)
View stochastic_control_flow.jl
using DrWatson
@quickactivate "DynamicPPL_NeurIPS"
using Turing
using LinearAlgebra
using Random: seed!
seed!(1)
@model testmodel(p, O) = begin
x ~ Categorical(p)
View mode_finding.jl
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))
View dpmm.jl
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
@trappmartin
trappmartin / gist:84ca6efbb8f47a6a36545da51894190c
Last active Aug 11, 2018
Change Julia 0.6 function syntax to Julia 1.0 using vim
View gist:84ca6efbb8f47a6a36545da51894190c
%s/\({.*}\)\(([^)]*)\)\(\s=\)/\2 where \1\3/g
View vimrc
set nocompatible
color pablo
syntax on
set number
set backspace=indent,eol,start
" highlight found words
set hlsearch
" show matching parenthesis
@trappmartin
trappmartin / .bashrc
Last active Dec 1, 2017
.bashrc config
View .bashrc
#!/bin/bash
#######################################################
# EXPORTS
#######################################################
# Expand the history size
export HISTFILESIZE=10000
export HISTSIZE=500
# Set the default editor
You can’t perform that action at this time.