Assuming the random number generator is good, you just use the modulo
operator, i.e.,

if(call Random.rand16()%2 == 1) {
 // do something
} else {
 // do something else
}

Cheers,

- Thomas





On Mon, Mar 7, 2011 at 3:18 PM, aggeloko <[email protected]> wrote:
> Yes, but does this mean that the generator, for a given seed, produces
> random numbers inside [0, 2^32) ?
>
>  For instance, if I want to implement a probabilistic algorithm where it
> performs some actions with probability 50%, and some others with the same
> probability; then does it suffice to check the random generated number with
> (2^32)/2?
>
>
> Thnx in advance
> Marios
>
> On Sat, Mar 5, 2011 at 3:20 AM, Thomas Schmid <[email protected]>
> wrote:
>>
>> Look at the "Random" interface:
>>
>> http://www.tinyos.net/tinyos-2.1.0/doc/nesdoc/iris/ihtml/tos.interfaces.Random.html
>>
>> rand16 gives you a 16-bit random number, rand32 a 32-bit.
>>
>> Cheers,
>>
>> - Thomas
>>
>>
>>
>>
>>
>> On Fri, Mar 4, 2011 at 3:58 PM, aggeloko <[email protected]> wrote:
>> >
>> > Greetings everyone,
>> >
>> > could someone provide me with the range of numbers that RandomMlcgC
>> > generates with the Park-Miller Minimal Standard Generator?
>> >
>> > That is the minimum and the maximum number..
>> >
>> > Thanks in advance,
>> > Marios
>> >
>> >
>> > _______________________________________________
>> > Tinyos-help mailing list
>> > [email protected]
>> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>> >
>
>

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to