?Hi, I am working with lotteries and I need to generate two sets of uniform random numbers. Requirements: 1) each set has 60 random numbers 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) 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). For the computation of the expected value, the probabilities in each lottery are ? and ?. How do this? Any help given would be greatly appreciated. Thank you, Valeria PhD cognitive sciences University of Siena
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 numbersrandom 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
On Mon, 30 Apr 2012, Vale Fara wrote:> ok, what to do is to generate two sets (x,y) of integer uniform random > numbers so that the following condition is satisfied: the sum of the > numbers obtained in x,y matched two by two (first number obtained in x > with first number obtained in y and so on) is in mean equal to a value > z, mean value that I can decide before the randomization. > > Hope this is more clear than before...It isn't very clear to me. If you generate random X,Y pairs such that (X+Y)/2=z, then you have a only one random number and a nother that is completely dependent on it: X = random Y = 2z - X. I'll just tell you one thing you might be able to use, but I don't have time for this. To make a vector of N uniformly-distributed random integers in the range from integer A to integer B, inclusive, you can do this: floor( runif(N, min=A, max=B+1) ) The floor() function rounds down to the nearest integer. Depending on the exact nature of the algorithm, it might be possible for B+1 to happen, but it would be extremely unlikely, if it really is possible. This should do the same thing: floor((B-A+1)*runif(N)+A) The ceiling function can accomplish the same thing. To make random integers from 1 to K, do this: ceiling( K*runif(N) ) Mike