[R] generate random numbers for lotteries

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Sun Apr 29 16:31:51 CEST 2012



On Apr 29, 2012, at 2:25 AM, billy am <wickedpuppy at gmail.com> wrote:

> Interesting set of question.. I am completely new to R but let me try my
> luck.
> 
> Random number in R
> 
> x <- runif(60 , 0 , 10) # 60 numbers from 0 to 10
> y<-  runif(60, 15 , 25) # same as above , from 15 to 25
> 
> The second part though. Do you mean ,
> 
> for( i in 1:length(x)) {
> z = x[i] + y[i]
> return z
> }

This is both invalid syntax and non-idiomatic: you want a simple z = x+y

Michael

> 
> something like that? No idea about the third part though.
> 
> regards
> Billy
> 
> On Sun, Apr 29, 2012 at 9:29 AM, Mike Miller <mbmiller+l at gmail.com> wrote:
> 
>> 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<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
>> ______________________________________________
>> R-help at 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.
>> 
>> 
> 
> 
> -- 
> http://use-r.com  - R Statistics Scripting & Programming Language Online
> Community Home
> http://bam.domainpool.com - Domains For Sale
> http://SQLHack.net - Tech Blog/Tutorials
> 
> ------------------------------------------------------------------------------------
> 
> MCSA (Security) , MCSA , CCNA , LPIC - Lvl 1 , Security+ ,  Network+ , A+
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list