From eqqon
< User:Zelenka | Statistics
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
- 5.4
rand.norm <- function (n,mu , sigma ) {
r.n <- numeric (n)
for (i in (1:n)) {
r.u <- runif (12)
r.n[i] <- sum (r.u)-6 }
r.n <- mu+r.n* sigma }
mu<-100;
sigma<-10;
n<-500;
res<-rand.norm(n,mu,sigma)
tmp.hist <- hist(res , plot = FALSE )
mp.dens <- dnorm(mu,mean=mu,sd=sigma)
y.max<-max(tmp.hist$density,y.max)
hist(res ,breaks=seq(mu-4*sigma-1,mu+4*sigma+1,length=round(sqrt(n))+1),prob=TRUE,xlab="" ,ylab="",main=paste(" Mittel =",mu ," Streuung =", sigma ,"n=",n), ylim =c(0,y.max))
x<-seq(mu -4* sigma ,mu +4* sigma , length =100)
lines(x,dnorm(x,mu , sigma ),lty =1,lwd =2,col="red")
rug(res)