[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [oc] Again! modulo arithmetic hardware



Hi,

    You can try another solution for this problem. Since you should generate
a random number between [0..9], you should have chances of 1/10 for each
one. You could use comparators to create this number from a big one. If you
have an 8 bit random number ([0..255]) you can use the following limits for
your random number:
0 <= n < 26    => 0
26 <= n < 51  => 1
...
and so on. Since you should increment the numbers by 25,6 ,  you will have
to round them. But you can make the source random number big enough to
minimize this error.

        Rodolfo

----- Original Message -----
From: "Tobin Fricke" <tobin@splorg.org>
To: <cores@opencores.org>
Sent: Monday, March 11, 2002 7:35 AM
Subject: Re: [oc] Again! modulo arithmetic hardware


>
>
> On Mon, 11 Mar 2002, Marko Mlinar wrote:
>
> > > 2) Generate a random number of 9 bits (or larger) in width. Use a >
> > logic core that inputs of 9 bits and outputs the count of bits > set.
>
> > I am not an expert in random math, but I would say this new distribution
> > is not random anymore.
>
> You're right, too.  Actually, the output of this process will be random,
> but the distribution won't be flat.  Some numbers will be much more
> probable than others.  A simple simulation should show this quite readily.
>
> It turns out that this scheme generates the binomial distribution.
>
> ( http://mathworld.wolfram.com/BinomialDistribution.html )
>
> It's pretty easy to compute the probability for each of the outputs { 0,
> 1, ... 9 }.  To get X as an ouput, we need to have exactly X bits set out
> of 9.  The probability of getting X is then the number of combinations of
> nine bits with exactly X set multiplied by the probability of each
> combination.  The number of combinations is given by the binomial function
> y!/(x!(y-x)!) with y=9 and each combination has probability (1/2)^9.
>
> The resulting probabilities are:
>
> 0: 0.00195
> 1: 0.01758
> 2: 0.07031
> 3: 0.16406
> 4: 0.24609
> 5: 0.24609
> 6: 0.16406
> 7: 0.07031
> 8: 0.01758
> 9: 0.00195
>
> Note that it is, for example, 126 times more likely to get a 4 or a 5 than
> it is a 0 or a 9.
>
> I suggest the original poster refer to Knuth who wrote extensively on
> psuedorandom sequence generation.
>
> Tobin
>
>
>
> --
> To unsubscribe from cores mailing list please visit
http://www.opencores.org/mailinglists.shtml
>

--
To unsubscribe from cores mailing list please visit http://www.opencores.org/mailinglists.shtml