Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacob Carey jacobcvt12

View GitHub Profile
View .nvimrc
" -----------------------------------------------------------
"
" 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 Jan 18, 2018
Talk about ABC and Convergence
View abc_convergence.R
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 Apr 4, 2017
Automatic Differentiation to calculation score function with Julia
View forwarddiff-score-function.jl
# 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
View r_benchmark.R
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)