@dufus

tell me 1 thing
do we have to make algo so that the prob is 1/7 or do we have to make so
that prob of generating number between 1 to 7 is same may be( 1/10) etc ???

On Tue, Sep 8, 2009 at 11:42 AM, Dufus <rahul.dev.si...@gmail.com> wrote:

>
> Hardest part of this problem is to prove that the generated number
> INDEED follow uniform distribution :D
>
> _dufus
>
>
> On Sep 8, 6:57 am, Dave <dave_and_da...@juno.com> wrote:
> > Use the rejection technique, something like this:
> >
> > do
> > {
> >     do
> >         U1 = random_1_to_5();
> >     while( U1 == 5 );
> > // At this point, U1 is a uniform integer in the range 1 to 4.
> >     U2 = random_1_to_5();
> >     if( U1 > 2 )
> >         U2 += 5;}
> >
> > while( U2 > 7 );
> > // At this point, U2 is a uniform random integer in the range 1 to 7.
> >
> > It takes on average 45/14 1_to_5 random numbers to make a 1_to_7
> > random number.
> >
> > Dave
> >
> > On Sep 7, 10:56 am, ankur aggarwal <ankur.mast....@gmail.com> 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)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to