Skip to content

Instantly share code, notes, and snippets.

@georgepsarakis
Created October 28, 2013 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgepsarakis/7194944 to your computer and use it in GitHub Desktop.
Save georgepsarakis/7194944 to your computer and use it in GitHub Desktop.
Probability counter (binary)
from random import getrandbits
def probability_counter(counter=None):
if counter is None:
counter = 1
counter += int((getrandbits(counter) + 1) >> counter == 1)
return counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment