Skip to content

Instantly share code, notes, and snippets.

@goldingn
goldingn / circleplot_mre.R
Created November 21, 2014 13:29
minimal reproducible example of the bug in circleplot
# load devtools and install the preferred version of circleplot
library(devtools)
install_github('mjwestgate/circleplot')
#install_github('goldingn/circleplot')
library(circleplot)
# set RNG seed
set.seed(1)
# create a fake symmetric matrix
@goldingn
goldingn / fuzzyMatch.R
Created October 29, 2014 17:47
no frills fuzzy matching for character vectors in R
fuzzyMatch <- function (a, b) {
# no-frills fuzzy matching of strings between character vectors
# `a` and `b` (essentially a wrapper around a stringdist function)
# The function returns a two column matrix giving the matching index
# (as `match` would return) and a matrix giving the distances, so you
# can check how well it did on the hardest words.
# Warning - this uses all of your cores.
# load the stringdist package
@goldingn
goldingn / geti
Created October 8, 2014 10:28
return the elements of an array of unknown dimension at the ith index on the first dimension
geti <- function (x, i) {
# return the elements of an array `x` of unknown dimension
# at the ith index of its first dimension
# throw an error if x isn't an array
stopifnot(is.array(x))
# get the dimension of x
k <- length(dim(x))
@goldingn
goldingn / zoon_sketch.R
Created June 17, 2014 17:12
Rough sketch of ZOON modular structure
# _____________ ____________ ____________ ___________________
# \ ______ \__ _\ ______ \ _\ ______ \ _\ ___ \______
# \ / \ \ \ \ \ \__ _\ \ \ \ \ _\ \ \/ \ \_____
# \ / \ \ \ \ \ \ \ \ \ \ \ \__ _\ \ \ \ \ \____
# \ /______ \ \ \ \_____\ \ \ \ \ \_____\ \ \ \ \ \ \ \ \___
# \___________\__\_\___________\__\_\_\___________\__\_\_\_\___________\__
# \____________\___\_\____________\___\_\_\____________\__
# \____________\_____\_\____________\___
# SPECIES DISTRIBUTION MODELLING \____________\____
#
@goldingn
goldingn / pop_maxent.R
Created May 12, 2014 10:44
Playing with probability-of-presence from Maxent-type models
# converting maxent/Poisson model output to true probability of presence
# clear workspace
rm(list = ls())
# set rng seed
set.seed(1)
# number of datapoints
n <- 100000
@goldingn
goldingn / CUR4FIC
Last active January 3, 2016 05:49
Playing with CUR decomposition (versus k-means) as a method for picking inducing points in sparse Gaussian processes
# clear the workspace
rm(list = ls())
# load the relevant libraries
# install.packages(rCUR)
library(rCUR) # for CUR decomposition
# install.packages(irlba)
library(irlba) # for fast svd