⚠️ Warning: This is a draft ⚠️
This means it might contain formatting issues, incorrect code, conceptual problems, or other severe issues.
If you want to help to improve and eventually enable this page, please fork RosettaGit's repository and open a merge request on GitHub.
==Probabilities are weird!== After completing my unbiasing function:
def unbiased(biased): 'uses a biased() generator of 1 or 0, to create an unbiased one' this, that = biased(), biased() while this == that: # Loop until 10 or 01 this, that = biased(), biased() return this # return the first
I took a look and thought about those two calls to biased() in the inner loop. "It should work with just one call" I thought. (All the while thinking that this is probability and it always bites me).
I could not resist. I reasoned that all I was looking for is a 1,0 or 0,1 in the stream generated by biased() it should not matter if I look at non-overlapping pairs, as above, or just slide along a two bit window into the stream like this:
def unbiased(biased): 'uses a biased() generator of 1 or 0, to create an unbiased one' this, that = biased(), biased() while this == that: # Loop until 10 or 01 this, that = that, biased() #<<< return this # return the first
Sure enough the change fails. It is just as biased as the biased generator.
I guess I'm doomed to never intuit probabilities; but at least I remember that most times now :-) --[[User:Paddy3118|Paddy3118]] 07:19, 22 February 2011 (UTC)
:Just in case you have not worked this out yet: the issue here is that 0 0 is much more likely than 1 1, so when you iterate, your new value of 'this' will almost always be zero. --[[User:Rdm|Rdm]] 16:18, 22 February 2011 (UTC) ::I was leaning towards that explanation. Thanks for the confirmation. --[[User:Paddy3118|Paddy3118]] 16:51, 22 February 2011 (UTC)