Skip to content

Instantly share code, notes, and snippets.

View willpearse's full-sized avatar

Will Pearse willpearse

  • Imperial College London
  • Silwood Park, UK
  • X @willpearse
View GitHub Profile
@willpearse
willpearse / pareto-bm-noodling.R
Last active November 5, 2021 17:55
Distributions of body mass noodling for sDevTraits
# Rough-and-ready body-mass/species-number estimation in mammals and birds
# Will Pearse - 2021-09-19
##########################
# Load data ##############
##########################
library(caper)
library(ape)
library(Pareto)
@willpearse
willpearse / toy-mcmc.R
Created October 24, 2021 13:43
Toy MCMC
data <- c(120, 130, 110, 105, 121)
n.iter <- 10000
mu.prior <- function(x) dnorm(x, mean=0, sd=10)
sd.prior <- function(x) dnorm(x, mean=0, sd=10)
posterior <- function(x, mu, sigma) sum(c(
dnorm(x, mu, abs(sigma), log=TRUE),
mu.prior(x), sd.prior(x)
))
proposal <- function(x) x + rnorm(1, 0, sd=.25)
mu <- 90