Skip to content

Instantly share code, notes, and snippets.

Created April 28, 2015 13:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Which normal Q-Q plot is of the real data?
qqfind <- function(x) {
# Generates the normal Q-Q plot for the given data
# as well as for three samples of the same size
# from a normal distribution with matching
# mean and variance.
# If it's obvious which one is the real data,
# it might not be normally distributed.
# Return value is the index of the plot
# of the real data.
mean <- mean(x)
sd <- sd(x)
par(mfrow=c(2, 2))
real <- sample(1:4, 1)
for (i in 1:4) {
if (i == real) {
} else {
y <- rnorm(length(x), mean, sd)
par(mfrow=c(1, 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment