Last active
August 29, 2015 14:04
-
-
Save leoschet/54bc0b30126ae902c733 to your computer and use it in GitHub Desktop.
R code
This file contains hidden or 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
# author: ljsa @ cin.ufpe.br | |
# sd = Standart deviation | |
# confidence = (0~1) | |
# Obj: ver se o estado esta dentro da area de confianca da media | |
plotNorm = function(mean, sd, confidence){ | |
curve (dnorm(x, mean, sd), xlim = c(mean - (3*sd), mean + (3*sd))); | |
left = (1-confidence)/2; | |
right = confidence + L; | |
# funcao qnorm me retorna o ponto da normal de x | |
dotL = qnorm(left, mean, sd); | |
dotR = qnorm(right, mean, sd); | |
interval = 0.01; | |
cordX <- c(dotL, seq(dotL, dotR, interval), dotR); | |
cordY <- c(0, dnorm(seq(dotL, dotR, interval), mean, sd), 0); | |
polygon(cordX, cordY, col = "skyblue"); | |
polygon(c(mean, mean), c(0, dnorm(mean,mean,sd)), border="darkblue"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment