Skip to content

Instantly share code, notes, and snippets.

@ma2rten
Created April 13, 2014 15:32
Show Gist options
  • Save ma2rten/10588811 to your computer and use it in GitHub Desktop.
Save ma2rten/10588811 to your computer and use it in GitHub Desktop.
def p_ben(n, history_length):
p_remove = .3
p_keep = 1 - p_remove
if n == 1:
return 0.
if n == history_length:
return p_keep ** (n-2)
return p_keep ** (n-2) * p_remove
def p_utnap(n, history_length):
if n < 2:
return 0.
censored = history_length - n
normalization = sum(log(k) for k in range(2, history_length+1))
return log(censored + 2) / normalization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment