Skip to content

Instantly share code, notes, and snippets.

View JoFrhwld's full-sized avatar

Josef Fruehwald JoFrhwld

View GitHub Profile
@JoFrhwld
JoFrhwld / install_brms.R
Created June 16, 2023 15:33
My brms install as of 2023-06-16
View install_brms.R
# I don't understand why or how this
# plus what's in Makevars works, but it's
# the only way I can get rstan & brms installed\
# see also: https://github.com/stan-dev/rstan/issues/1070#issuecomment-1570565599
# renv::init(bare = TRUE)
Sys.setenv(MAKEFLAGS = "-j4") # four cores used
install.packages(c("Rcpp", "RcppEigen", "RcppParallel", "StanHeaders"), type = "source")
install.packages("rstan", type = "source")
View mkproj.sh
#!/bin/sh
x="Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
@JoFrhwld
JoFrhwld / align_chunks.py
Last active July 1, 2022 21:41
Given two pandas data frames of time stamped transcription chunks of the same audio, return the smallest possible span of aligned chunks between the two.
View align_chunks.py
import pandas as pd
def align_chunks(X_df, Y_df, A_idx_list, B_idx_list, state, **kwargs):
"""
Given X_df and Y_df, return the dataframes (A_df and B_df) with the
smallest possible span of overlapping transcription chunks.
Function operates recursively.
"""
@JoFrhwld
JoFrhwld / revlog.R
Created March 31, 2012 17:32
ggplot2 reverse log coordinate transform
View revlog.R
## ggplot2 and mgcv for the plot
library(ggplot2)
library(mgcv)
## scales packages to define revlog
library(scales)
revlog_trans <- function(base = exp(1)){
## Define the desired transformation.
trans <- function(x){
View exitpoll.Rmd
---
title: "R Notebook"
output: html_notebook
---
Source:
https://edition.cnn.com/election/2016/results/exit-polls
```{r}
View header.Rmd
---
title: "Building up and evaluating models"
output:
html_notebook:
code_folding: none
css: ../custom.css
theme: flatly
toc: yes
toc_depth: 3
toc_float: yes
View header.Rmd
---
title: "Building up and evaluating models"
output:
html_notebook:
code_folding: none
css: ../custom.css
theme: flatly
toc: yes
toc_depth: 3
toc_float: yes
View sigma_tween.R
library(tweenr)
library(gganimate)
library(ggplot2)
library(tidyverse)
#' define the 4 states
state1 <- data_frame(mean = 0,
sd = 1)
state2 <- data_frame(mean = 0,
sd = 3)
@JoFrhwld
JoFrhwld / purrr_bootstrap.R
Created July 29, 2017 20:06
Using purrr to do bootstrap estimation of the mean
View purrr_bootstrap.R
library(tidyverse)
replicates <- (1:100000)%>%
map(~sample(faithful$waiting, replace = T))%>%
map(mean)%>%
simplify()
data_frame(replicates = replicates)%>%
ggplot(aes(replicates))+
stat_density()
@JoFrhwld
JoFrhwld / purrr_bootstrap.R
Created July 29, 2017 20:06
Using purrr to do bootstrap estimation of the mean
View purrr_bootstrap.R
library(tidyverse)
replicates <- (1:100000)%>%
map(~sample(faithful$waiting, replace = T))%>%
map(mean)%>%
simplify()
data_frame(replicates = replicates)%>%
ggplot(aes(replicates))+
stat_density()