Skip to content

Instantly share code, notes, and snippets.

View selftext's full-sized avatar

Jeremy Salfen selftext

View GitHub Profile
@selftext
selftext / generate_standard_normal_distribution.r
Last active August 29, 2015 14:23
Generate a standard normal distribution to import into a database as a lookup table
library(dplyr)
# create data frame of z-scores and probabilities
standard_normal_distribution <- data.frame(z_score = seq(-7, 7, 0.000001),
probability = pnorm(seq(-7, 7, 0.000001)))
# find max number of characters (redshift has a limit of DECIMAL(38, 37))
max(nchar(standard_normal_distribution$probability))
# if necessary, round big decimals
@selftext
selftext / G-test
Created October 28, 2012 14:07
G-test for goodness of fit in R
> x <- c(22.69,23.84,24.77,25.84,26.79,27.74,28.67,30.41)
> y <- c(5,4,17,21,15,20,15,14)
> ny <- c(9,10,11,18,7,4,3,0)
> ymat <- cbind(y,ny)
> m1 <- glm(ymat ~ x, family=binomial)
> summary(m1)
Call:
glm(formula = ymat ~ x, family = binomial)