Skip to content

Instantly share code, notes, and snippets.

View jacobcvt12's full-sized avatar

Jacob Carey jacobcvt12

View GitHub Profile
" -----------------------------------------------------------
"
" Description: .vimrc file (vim configurations)
" Maintainer: Jacob Carey <jacobcvt12@gmail.com>
"
" -----------------------------------------------------------
" 1. General Settings {{{1
" enable hybrid rnu
set relativenumber
@jacobcvt12
jacobcvt12 / abc_convergence.R
Created January 18, 2018 21:58
Talk about ABC and Convergence
set.seed(1) # reproducibility
S <- 1000 # number of desired samples from posterior
theta_true <- 3.4 # true mean
n <- 1000 # number of data points
y <- rnorm(n, theta_true) # observed data
theta <- rnorm(S, 0, 10) # allocate chain for mean
@jacobcvt12
jacobcvt12 / forwarddiff-score-function.jl
Created April 4, 2017 21:14
Automatic Differentiation to calculation score function with Julia
# Automatic Differentiation example with forward accumulation
# Here we calculate the gradient of the loglikelihood of a normal
# distribution wrt to the mean and variance (i.e. the score function)
# load package for AD and Distributions
using ForwardDiff, Distributions
# parameters
μ = 10.0; # true mean
σ² = 1; # true variance
system.time({
library(gtools)
library(MASS)
### data
yg <- galaxies
yg[78] <-26960
yg <- yg/1000
set.seed(123)
nsim <- 1e6
theta1 <- rnorm(nsim, 20, 10)