Last active
January 26, 2016 00:09
-
-
Save heolin/3f6dd7f55f16eeb558e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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