Last active
November 23, 2018 22:06
-
-
Save ajstewartlang/422fda3a81f0b7186f940176cbed70d9 to your computer and use it in GitHub Desktop.
100000 samples with N=20 and no difference in population sampled from
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(tidyverse) | |
df <- NULL | |
set.seed(1111) | |
sample_size = 20 | |
for (i in 1:100000) { | |
a <- rnorm(sample_size, mean = 10, sd = 2) | |
b <- rnorm(sample_size, mean = 10, sd = 2) | |
a <- cbind(a, rep ("A", sample_size), rep (i, sample_size)) | |
b <- cbind(b, rep("B", sample_size), rep (i, sample_size)) | |
df <- as.tibble(rbind(df, (rbind(a, b)))) | |
} | |
colnames(df) <- c("Score","Condition", "Sample") | |
df$Score <- as.numeric(df$Score) | |
data <- NULL | |
for (i in 1:100000) { | |
toa <- as.tibble(cbind(filter(df, Sample==i & Condition=="A")$Score, | |
filter(df, Sample==i & Condition=="B")$Score)) | |
data <- rbind(data, tidy(t.test(toa$V1, toa$V2))) | |
} | |
ggplot(data, aes(x = p.value)) + geom_histogram() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment