[FoRK] low probability bits

Damien Morton dmorton at bitfurnace.com
Mon Feb 23 03:30:26 PST 2009


You're just not frugal enough with your random bits. Generating 32 (or 64!)
of them for every skewed bit you emit. Shame on you and your profligate
ways.
Its not like I am working on a supercomputer here.

Let me guess - your first programming language was Java, right?

On Mon, Feb 23, 2009 at 9:47 PM, Russell Turpin <russell.turpin at gmail.com>wrote:

> Y'all are working too hard.
>
> def genOnesToProb(p):
>    while True:
>        if p and random.random() <= p:
>            yield 1
>        else:
>            yield 0
>
> 1s, uniformly distributed, to any desired probability p.
> _______________________________________________
> FoRK mailing list
> http://xent.com/mailman/listinfo/fork
>


More information about the FoRK mailing list