?sample
efficient enough?> system.time(z <- sample(1:5, 50, TRUE,
prob=c(.05,.05,.05,.05,.8)))
user system elapsed
0.120.020.14
> table(z)
z
1 2 3 4 5
24800 24771 25039 25022 400368
>
On Sat, Sep 20, 2008 at 3:43 PM, John Sorkin <[EMAIL PROTECTED]>
R 2.6
Windows XP
I need to select from the integers 1,2,3,4,5 with some pre-determined
probability, e.g. probability of selecting 5 80%, probability of selecting 1 or
2 or 3 or 4 20%. Any suggestions for how I might accomplish this? I need to
do it very efficiently as I will be doing it 500,0
2 matches
Mail list logo