@ *ALL*
please. post along with your method .
proof than it make's equal distribution over the given range.
On Tue, Jun 19, 2012 at 4:47 AM, Navin Kumar <[email protected]>wrote:
> @Umer:
>
> rand(5) + (rand(5)%2): => it will never give 6 because for rand(7) range
> will be 0-6.
> So better try this: rand(5) + (rand(5)%3).
>
>
> On Tue, Jun 19, 2012 at 2:45 PM, Umer Farooq <[email protected]> wrote:
>
>> rand(5) + (rand(5)%2);
>>
>>
>> On Tue, Jun 19, 2012 at 12:30 PM, Sourabh Singh <[email protected]
>> > wrote:
>>
>>> @ sry
>>> condition should be:
>>>
>>> if(20*prob <= 500/7) :-)
>>>
>>>
>>> On Tue, Jun 19, 2012 at 12:26 AM, Sourabh Singh <
>>> [email protected]> wrote:
>>>
>>>> @ALL
>>>>
>>>> Given a random number generator say r(5) generates number between 1-5
>>>> uniformly at random , use it to in r(7) which should generate a random
>>>> number between 1-7 uniformly at random
>>>>
>>>> i have seen this on many site's but not a single correct solution. all
>>>> solution's posted got rejected by someone else.:
>>>> plz.. suggest some algo :
>>>>
>>>> my aprroach:
>>>>
>>>> let's assume a rectangle :
>>>>
>>>> 100 |___________________
>>>> |___________________|______
>>>> 500/7 | | |
>>>> | | |
>>>> |___________________|______|
>>>> 0 1 2 3 4 5 6 7
>>>> now :
>>>>
>>>> let : num = rand(5);
>>>> prob = rand(5);
>>>>
>>>> if(prob <= rand(5))
>>>> print num
>>>> else
>>>> print 5 + num*(2/5)
>>>>
>>>>
>>>> --
>>>> 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?hl=en.
>>>>
>>>
>>> --
>>> 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?hl=en.
>>>
>>
>>
>>
>> --
>> Umer
>>
>> --
>> 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?hl=en.
>>
>
> --
> 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?hl=en.
>
--
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?hl=en.