Skip to content

Instantly share code, notes, and snippets.

@heolin
Last active January 26, 2016 00:09
Show Gist options
  • Select an option

  • Save heolin/3f6dd7f55f16eeb558e2 to your computer and use it in GitHub Desktop.

Select an option

Save heolin/3f6dd7f55f16eeb558e2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from scipy.special import binom
def bernoulli(p, n, k):
return binom(n, k) * (p ** k) * ((1.0 - p) ** (n - k))
def main():
p = 1.0/50.0 #prawdopodobienstwo wylosowania tego elementu co trzeba w jednym losowaniu
n = 1000 #liczba losowan
k = 10 #ilosc potrzebnych takich samych elementow
print bernoulli(p, n, k)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment