This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ----------------------------------------------------------- | |
" | |
" Description: .vimrc file (vim configurations) | |
" Maintainer: Jacob Carey <jacobcvt12@gmail.com> | |
" | |
" ----------------------------------------------------------- | |
" 1. General Settings {{{1 | |
" enable hybrid rnu | |
set relativenumber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |