ok, this is a lame attempt  - can someone explain if it's correct, or
why not :

int limited_rand() {
   return rand() % 8 + 1;
}

value = limited_rand() % 3 + limited_rand();


On Jan 31, 7:29 am, "Ming \(Amos\) Zhang" <[EMAIL PROTECTED]> wrote:
> It's not uniformly distributed, suppose the given random generator is
> uniformly distributed
>
> -----Original Message-----
> From: algogeeks@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> Behalf Of Sandesh
> Sent: Tuesday, January 30, 2007 11:09 PM
> To: Algorithm Geeks
> Subject: [algogeeks] Re: (need help) How to solve this random number
> generatioin problem?
>
> suppose "given" function returns the random numbers between 1 -5  then
> you can have
>
>        (given + given) % 7 +1
>
> which will generate between 1 and 7 .
>
>        -Sandesh Hegde
>
> On Jan 31, 6:57 am, "Jialin" <[EMAIL PROTECTED]> wrote:
> > Question:
>
> > Given a program which can generate one of {1, 2, 3, 4, 5} randomly.
> > How can we get another generator which can generate one of
> > {1,2,3,4,5,6,7} randomly?
>
> > Thank you!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to