[R] generate random numbers for lotteries

Mike Miller mbmiller+l at gmail.com
Sun Apr 29 03:29:43 CEST 2012


On Fri, 27 Apr 2012, Vale Fara wrote:

> I am working with lotteries and I need to generate two sets of uniform
> random numbers.
>
> Requirements:
> 1) each set has 60 random numbers

random integers?

> 2) random numbers in the first set are taken from an interval (0-10),
> whereas numbers in the second set are taken from a higher interval
> (15-25)

Depends on if you mean integers.  R has functions.  Here's one:

http://www.astrostatistics.psu.edu/su07/R/html/stats/html/Uniform.html


> 3) numbers generated in the first set should be matched to numbers in
> the second set (row by row) so that the expected value of each couple
> of random numbers (i.e. of each lottery) is around to a given value
> (12.5 +/- 5, where 12.5 is the median value of the interval extremes).

Do you mean that the mean for the pair of numbers must be between 7.5 and 
17.5, inclusive?  That means the sum must be from 15 to 35.  Well, you are 
in luck because if you make the numbers as you suggested above, that will 
happen -- you don't have to do anything special to make it happen.


> For the computation of the expected value, the probabilities in each
> lottery are ½ and ½.

For what outcome?  You lost me.


> How do this? Any help given would be greatly appreciated.

I hope that helps.

Mike


More information about the R-help mailing list