>>>>> "glen" == glen herrmannsfeldt <gah@[EMAIL PROTECTED]
> writes:
glen> Raymond Toy wrote:
glen> (snip, I wrote)
glen> This is true if m is a power of two. I believe it isn't
necessarily
glen> true if m is not a power of two. It is very common, though, for
m
glen> to be a power of two. Otherwise, if I need random low bits I
divide
glen> by a prime number sort of near sqrt(m) before using it.
>> Do you take the remainder as the random number? If so, this has a
>> bias, so the result isn't quite uniform. May or may not matter.
glen> Divide by some fairly large prime, then mod the (small) number
Divide meaning an integer divide, and using the quotient, ignoring the
remainder? Yeah, that probably works well. But this being a DSP
group, maybe the bias would go away if you take, say the top 8 or 16
bits, pretend it's a fraction (Q8 or Q16) and multiply by 6, and take
the integer part.
I think that has no bias, except whatever is introduced by the
original random number generator.
Ray


|