Thanks for your great help!

I have now what I wanted.
For sure it's not well written and you can realize it with much less lines.
But it works and it's like how I wanted it to look like;


z1 <- rnorm(4500, mean=20, sd=5)
z2 <- rnorm(3600,  mean=28, sd=5)
z3 <- rnorm(1300,  mean=40, sd=7)
z4 <- rnorm(1200,  mean=10, sd=7)
z5 <- rnorm(1500,  mean=50, sd=5)
z6 <- rnorm(1500,  mean=10, sd=5)
z7 <- rnorm(1400,  mean=37, sd=3)
pop <- c(z1, z2, z3, z4, z5, z6, z7)

 meansN2 <- numeric()
 meansN10 <- numeric()
 meansN40 <- numeric()

for (i in 1:1000) {
                        x <- runif(2, min=1, max=15000)
                        x <- round(x)
                        sample <- c(pop[x])
                        meansN2 <- append(meansN2, mean(sample))
                                 }
for (i in 1:1000) {
                        x <- runif(10, min=1, max=15000)
                        x <- round(x)

                        sample <- c(pop[x])
                        meansN10 <- append(meansN10, mean(sample))
                                 }
for (i in 1:1000) {
                        x <- runif(40, min=1, max=15000)
                        x <- round(x)
                        sample <- c(pop[x])
                        meansN40 <- append(meansN40, mean(sample))
                                }

pop <- table(cut(pop,breaks=seq(from=-10, to=70, length.out=80)))

meansN2 <- table(cut(meansN2,breaks=seq(from=-10, to=70, length.out=80))) meansN10 <- table(cut(meansN10,breaks=seq(from=-10, to=70, length.out=80))) meansN40 <- table(cut(meansN40,breaks=seq(from=-10, to=70, length.out=80)))

pop <- smooth(pop)
meansN2 <- smooth(meansN2)
meansN10 <- smooth(meansN10)
meansN40 <- smooth(meansN40)

plot(pop, type="l", lwd=1.5)
lines(meansN2, lty="dotted", lwd=1.5)
lines(meansN10, lty="dashed", lwd=1.5)
lines(meansN40, lty="twodash", lwd=1.5)

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to