How are you picking ni from [a...b] range (length 7) ?
________________________________ From: avalon <[email protected]> To: Algorithm Geeks <[email protected]> Sent: Saturday, 19 September, 2009 2:16:47 PM Subject: [algogeeks] Re: random number... Forgive me first if i am wrong since i didn't read all the posting ... Here is a way to sol the problem. n1 = random_1_5() + 0; n2 = random_1_5() + 5; .. n7= random_1_5() + (7-1)*5; now n1 ... n7 is in range [1 ... 35] Image we divde the range [1.. 35] into 5 parts, such as [1...7] , [8...14] ... then we generat n8 = random_1_5() we use n8 to pick a part we divided above. so we get a range [a...b] , then we can get a number ni inside the range, return ni; ankur aggarwal <[email protected]> wrote: > Given a random number generator that generates numbers in the range 1 to > 5, how can u create a random number generator to generate numbers in the > range 1 to 7. (remember that the generated random numbers should follow a > uniform distribution in the corresponding range) Try the new Yahoo! India Homepage. Click here. http://in.yahoo.com/trynew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---
