Skip to content
Prev 310460 / 398506 Next

Counting the numbers of items in vector according to their size

Hello,

As you know R better it will take you less and less time to get it 
right, and almost surely less and less lines of code to do the same 
thing. Here's a one liner:


set.seed(1510)
s=numeric(length=100000)
for(i in 1:100000){
   pop=(rbeta(n=20,shape1=2,shape2=1))
   s[i]=sum(pop)
}

set.seed(1510)
s2 <- replicate(1e5, {sum(rbeta(n=20,shape1=2,shape2=1))})

identical(s, s2)  # TRUE

As for your question,

hist(s, breaks="Scott")  # Looks normal to me

You can use asymptotic normal theory.

Hope this helps,

Rui Barradas


Em 09-11-2012 17:57, rlcorp escreveu: