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
#!/bin/bash | |
# | |
# Compare two PDF files. | |
# Dependencies: | |
# - pdfinfo (xpdf) | |
# - pdfjam (texlive-extra-utils) | |
# - diffpdf | |
# |
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
library(dplyr) | |
sbc_cmd <- function (cmdstanrmodel, data, M, ...) | |
{ | |
stan_code <- cmdstanrmodel$code() | |
stan_code <- scan(what = character(), sep = "\n", quiet = TRUE, | |
text = stan_code) | |
pars_lines <- grep("[[:space:]]*(pars_)|(pars_\\[.*\\])[[:space:]]*=", | |
stan_code, value = TRUE) | |
if(length(pars_lines)==1){ |
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
oo <- ls(envir=.GlobalEnv) | |
purrr::map_chr(oo, ~ do.call(pryr::address,list(rlang::sym(.x))) ) %>% | |
setNames(oo) %>% | |
tibble::enframe() |
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
library(dplyr) | |
library(purrr) | |
library(ggplot2) | |
data <- tibble(b= rnorm(1000), RT= rlnorm(1000,-.3+b,.3), correct= rbinom(1000, 1, plogis(b))) | |
pdata <- data %>% mutate(quantiles=list(quantile(RT,c(.1,.3,.5,.7,.9,1))), q = map_dbl(RT, ~ which(.x <= quantiles[[1]] ) %>% min )) %>% | |
select(-quantiles) %>% group_by(q) %>% summarize(RT=mean(RT),p= mean(correct)) | |
ggplot(pdata, aes(x=p,y=RT)) + geom_point() + geom_line() |
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
library(eegUtils) | |
library(tidyverse) | |
library(magrittr) | |
### Import dat needs a lot of information, since dat files don't contain any meta data | |
import_dat <- function(file_name, data_points, chan_info, | |
srate, event_table = NULL, orientation = "vectorized", | |
domain = "time") { | |
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
softmax <- function(probs){ | |
if(is.null(dim(probs))) probs <- matrix(probs,ncol= length(probs)) | |
exp(probs)/apply(probs,1, function(x) sum(exp(x))) | |
} |
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
functions { | |
matrix helmert(int levels) { | |
matrix[levels, levels - 1] m = rep_matrix(-1, levels, levels - 1); | |
real k = 0; | |
for(j in 1:(levels - 1)) | |
for(i in 1:levels) | |
if(j <= i - 2) | |
m[i, j] = 0; | |
else if(j == i - 1) { | |
k = k + 1; |
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
# Regular expressions I've used to convert a tex file using Biblatex to apacite: | |
(?s)cites{([^{}]*?)}{ | |
cites{\1, | |
(?s)cites{([^{}]*?)}\n{ | |
cites{\1, | |