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
credentials.py | |
__pycache__/ | |
archived_tweets*.json |
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
# James Keirstead | |
# 20 November 2016 | |
library(TSP) | |
#' Draw names for a Secret Santa gift exchange | |
#' | |
#' In a 'Secret Santa' gift exchange, a group of people are randomly divided | |
#' into pairs. These pairs could be drawn in many different ways, depending on | |
#' whether the pairs are reciprocal and whether all pairs combinations are |
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
category | value | sector | |
---|---|---|---|
UK production emissions | 632 | UK | |
Carbon flows from EU | 88 | EU | |
Carbon flows to EU | -61 | EU | |
Carbon flows from other Annex 1 | 82 | Annex 1 | |
Carbon flows to other Annex 1 | -39 | Annex 1 | |
Carbon flows from non-Annex 1 | 104 | Other non-Annex 1 | |
Carbon flows from non-Annex 1 | 64 | China | |
Carbon flows to non-Annex 1 | -25 | Non-Annex 1 | |
UK consumption emissions | 845 | UK |
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
## Define the problem data | |
x <- read.csv("x-values.csv")$x | |
## Fit the power law. Looks okay with plots | |
library(poweRlaw) | |
mod <- conpl$new(x) | |
xmin <- estimate_xmin(mod, xmins=head(sort(x), n=10)) | |
mod$setXmin(xmin) | |
pars <- estimate_pars(mod) | |
mod$setPars(pars) |
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
##' Converts a vector of values to a formatted prose list | |
##' | |
##' @param vals a vector of values | |
##' @param oxford a boolean indicating whether Oxford comma should be used | |
##' @param and word before ultimate entry | |
##' @return a character string | |
prose_vector <- function(vals, oxford=FALSE, and="and") { | |
if (length(vals)>1) { | |
start <- head(vals, -1) | |
start <- paste0(start, collapse=", ") |
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
# Analysis of EPSRC fellowship success rates | |
# 18 November 2013 | |
# James Keirstead | |
##' Calculates the bounds for a funnel plot | |
##' | |
##' Calculates the upper and lower confidence interval limits for use | |
##' in a funnel plot. Assumes a binomial discrete distribution with a | |
##' probability of success theta. | |
##' |
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
## List the functions in a file, or if not specified the global environment | |
## | |
## @param src an optional source file | |
## | |
## @return a character vector of function names | |
ls_functions <- function(src=NULL) { | |
if (is.null(src)) { | |
classes <- sapply(ls(.GlobalEnv), function(x) class(eval(parse(text=x)))) | |
} else { | |
e <- new.env() |
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
// Predict from Gaussian Process | |
// All data parameters must be passed as a list to the Stan call | |
// Based on original file from https://code.google.com/p/stan/source/browse/src/models/misc/gaussian-process/ | |
data { | |
int<lower=1> N1; | |
vector[N1] x1; | |
vector[N1] y1; | |
int<lower=1> N2; | |
vector[N2] x2; |
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
## District heating AHP example | |
## | |
## This example demonstrates how the analytic hierarchy process can be | |
## used to select a preferred technique for forecasting the thermal | |
## load of a district heating system. | |
## | |
## James Keirstead ([email protected]) | |
## Presented 25 June 2013 at ISIE Conference, Ulsan, South Korea | |
## |
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
#' Calculate analytic hierarchy process weights | |
#' | |
#' The analytic hierarchy process (AHP) can be used for multi-criteria | |
#' decision analysis. It performs a pairwise comparison of a list of | |
#' options, with a respect to a particular goal. | |
#' | |
#' @detail The script will ask you to compare pairs of options. | |
#' Answer each question with respect to the statement goal and use | |
#' scores from 1,3,5,7,9 (or their inverse) where 1 = equally | |
#' important, 3 = moderately preferred, 5 = strongly preferred, 7 = |
NewerOlder