Skip to content

Instantly share code, notes, and snippets.

View psolymos's full-sized avatar
🏠
Working from home

Peter Solymos psolymos

🏠
Working from home
View GitHub Profile
## Welch t-test
### Simple Normal-Normal example
mu1 <- 1
mu2 <- 2
var1 <- 1
var2 <- 0.5
n <- 10^3
y1 <- rnorm(n, mu1, sqrt(var1))
y2 <- rnorm(n, mu2, sqrt(var2))
@psolymos
psolymos / sigma-bias
Created January 19, 2017 22:13
Bayesian approach systematically overestimates sigma (SD)
library(dclone)
set.seed(1)
## Bayesian estimate of sigma
N <- 9
intcept <- 1
sigma <- 1
Y <- rnorm(N, intcept, sigma)
dat <- list(Y=Y, N=N)
# COVID-19 cases in Alberta, Canada
# cases over time and some analyses
library(PVAClone)
dat <- data.frame(
date=c("2020-03-05", "2020-03-06", "2020-03-07", "2020-03-08", "2020-03-09", "2020-03-10", "2020-03-11",
"2020-03-12", "2020-03-13", "2020-03-14", "2020-03-15", "2020-03-16"),
cases=c(1, 2, 2, 4, 7, 14, 19,
23, 29, 39, 56, 74))
@psolymos
psolymos / index.R
Created April 21, 2020 20:51
Generative art animation with the magick package
library(tidyverse)
library(magick)
# functions from https://github.com/djnavarro/ashtree
# helper functions --------------------------------------------------------
radians <- function(degree) {
2 * pi * degree / 360
}
@psolymos
psolymos / r-apis
Last active April 3, 2023 19:33
Hello world examples with different R web frameworks
# httpuv
library(httpuv)
handle <- function(req) {
input <- req[["rook.input"]]
postdata <- input$read_lines()
jsonlite::toJSON(paste0("Hello ",
jsonlite::fromJSON(paste(postdata)), "!"))
}
httpuv::runServer(
host = "0.0.0.0",