Advertisement
joselucas000

gra_fdp_nor

Aug 11th, 2023
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.75 KB | Science | 0 0
  1. #
  2. ## Grafico de uma FDP + Normal
  3. #
  4.  
  5. #variaveis iniciais (gerando matriz de dados aleatoria)
  6.  x1 <- sample(1:100, 1)
  7.  x2 <- sample(101:200, 1)
  8.  vx <- sample(x1:x2, 1)     #para gerar uma dupla camada de aleatoridade
  9. dad <- rnorm(vx, mean=0, sd=1)
  10. med <- mean(dad); medx <- round(med, 2)
  11. des <- sd(dad); desx <- round(des, 2)
  12.  
  13. leg1 <- paste0("valor de x ", "(n= ", vx, ")")
  14. plot(density(dad), xlim=c(-4, 4), ylim=c(0, 0.8), bty="l",
  15.     mgp=c(2.5, 0.7, 0), xlab=leg1, ylab="probabilidade",
  16.     main="Funcao Densidade de Probabilidade - FDP")
  17. plot(function(x) dnorm(x, med, des), from=-4, to=4,
  18.     add=TRUE, col=2, lty=2)
  19. leg2 <- paste0("X ~ N( ", medx, ", ", desx, ")")
  20. legend(x="topright", legend=c(leg2, "observado"),
  21.     lty=c(2, 1), col=c(2, 1), bty="n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement