Skip to content

Instantly share code, notes, and snippets.

View alexpghayes's full-sized avatar

alex hayes alexpghayes

View GitHub Profile
@rasmusab
rasmusab / bowling-t-test.R
Created February 20, 2023 16:45
A much improved bowling T-test in R
bowling_animation_urls <- c(
"0.01" = "https://i.imgur.com/Kn8CQbj.gif",
"0.05" = "https://i.imgur.com/HFTKdDL.gif",
"0.1" = "https://i.imgur.com/8Sw54Mz.gif",
"1" = "https://i.imgur.com/kjROdhj.gif"
)
# We need to download the animations to the session temp dirercorty to display
# them in the Rstudio Viever pane
bowling_animation_html <- sapply(bowling_animation_urls, function(url) {
@kennedymwavu
kennedymwavu / .Rprofile
Last active June 18, 2023 23:00
Customize R's startup msg on Rstudio
setHook("rstudio.sessionInit", function(newSession) {
cat('\f')
hour <- format(Sys.time(), format = '%H') |> as.numeric() |> as.character()
morning <- 0:11
afternoon <- 12:16
evening <- c(17:23)
day_hrs <- rep(

Problem statement from Alex Hayes

i have (x, y) pairs generated from two smooth curves, but i don't know which curve each point comes from

is there a way to recover the original curves?https://t.co/h9kL2JEeEV pic.twitter.com/tzy4O1VnrT

— alex hayes (@alexpghayes) June 28, 2022
library(tidyverse)

x <- seq(0, 10, length.out = 100)

unobserved <- tibble(
@0xabad1dea
0xabad1dea / copilot-risk-assessment.md
Last active September 11, 2023 10:21
Risk Assessment of GitHub Copilot

Risk Assessment of GitHub Copilot

0xabad1dea, July 2021

this is a rough draft and may be updated with more examples

GitHub was kind enough to grant me swift access to the Copilot test phase despite me @'ing them several hundred times about ICE. I would like to examine it not in terms of productivity, but security. How risky is it to allow an AI to write some or all of your code?

Ultimately, a human being must take responsibility for every line of code that is committed. AI should not be used for "responsibility washing." However, Copilot is a tool, and workers need their tools to be reliable. A carpenter doesn't have to

@teunbrand
teunbrand / midiplot.R
Last active July 5, 2020 00:37
Making a plot of a midi file
library(ggplot2)
library(tuneR)
midi <- tuneR::readMidi("https://www.8notes.com/school/midi/piano/beethoven_ode_to_joy.mid")
df <- tuneR::getMidiNotes(midi)
# Difference between first two notes
mult <- 960
# Generalized Matrix Factorization
def GMF(num_users, num_items, k, reg):
"""Models the interaction between user/item LV w/ linear dot-product"""
print("using dot-product interaction term")
seed = 1
uid = Input((1,), name="uid")
iid = Input((1,), name="iid")
item_bias = Embedding(
@eric-pedersen
eric-pedersen / extr-varying-starts.R
Last active May 30, 2020 17:38 — forked from dill/extr.R
Forecasting with B-splines
library(mgcv)
# annual diameter of women’s skirts at the hem 1866 to 1911
# Hipel and McLeod, 1994
skirts <- scan("http://robjhyndman.com/tsdldata/roberts/skirts.dat",skip=5)
skirtseries <- data.frame(year=1866:1911, diam=skirts)
# prediction grid
pd <- data.frame(year=seq(1864, 1960, by=1))
@dill
dill / extr.R
Created May 29, 2020 06:44
Forecasting with B-splines
# extrapolating into the future with B-splines
# based on code in ?smooth.construct.bs.smooth.spec
library(mgcv)
# annual diameter of women’s skirts at the hem 1866 to 1911
# Hipel and McLeod, 1994
skirts <- scan("http://robjhyndman.com/tsdldata/roberts/skirts.dat",skip=5)
skirtseries <- data.frame(year=1866:1911, diam=skirts)
super_split <- function(data, ...) {
  dots <- rlang::quos(...)
  for (var in seq_along(dots)) {
    var_name <- rlang::as_name(dots[[var]])
    data <- purrr:::map_depth(
      data, 
      var - 1, 
      function(xs) split(xs, xs[var_name])
    ) 
@stablemarkets
stablemarkets / corr_mod.stan
Last active April 27, 2020 16:59
Smoothed logistic growth with time-varying carrying capacity.
data {
int<lower=0> num_obs; // number of observations
real y[num_obs]; // Observed value
int time[num_obs]; // time
}
parameters {
//weakly uninformative priors, K on log base 10 scale
vector[100] log_K;
real<lower=0,upper=100> p0;