Skip to content

Instantly share code, notes, and snippets.

@nashutoing
Created March 20, 2019 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nashutoing/344ca32995d3c71ce72fea32df3a34c7 to your computer and use it in GitHub Desktop.
Save nashutoing/344ca32995d3c71ce72fea32df3a34c7 to your computer and use it in GitHub Desktop.
Q-Qplot for rnorm(100) and normal distribution
rn<- rnorm(100) #make 100 random numbers followed by N(0,1)
rns<- sort(rn) #sort or order by ascending order(essential?)
plot(rns) #No useful(x-axis is represented as index)
rnss<- ecdf(rns) #ready for making cumlative function
par(mfrow=c(1,3)) #divide to set 3 graphs
plot(rnss) #cumlative function for rnorm(100)
abline(h=0.4) #draw horizon=0.4 line
curve(pnorm(x,0,1),xlim=c(-3,3))
abline(h=0.4) #pnorm=cumlative function for normal distribution
qqnorm(rn,qtype="Type9") #make qqplot
abline(h=-0.24) #draw h=-0.24 line
abline(v=-0.25) #draw h=-0.25 line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment