Created
December 7, 2017 18:20
-
-
Save initbar/4007b983a52e7eb895f87b028afc6694 to your computer and use it in GitHub Desktop.
This file contains 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 python | |
from bashplotlib.histogram import plot_hist | |
import random | |
import sys | |
if __name__ == '__main__': | |
if sys.argv[1] == 'a': | |
samples_a = [ random.choice([0,1]) for x in range(1*10**6) ] | |
print('[sample_a] 1 => %i' % samples_a.count(1)) | |
print('[sample_a] 0 => %i' % samples_a.count(0)) | |
print('\n[sample_a] ratio 1/0 => %f' % ( | |
float(samples_a.count(1)) / samples_a.count(0))) | |
print('-'*40) | |
plot_hist(samples_a) | |
else: | |
samples_b = [ random.random() for x in range(1*10**6) ] | |
samples_b = map(lambda x:int(round(x)), samples_b) | |
print('[sample_b] 1 => %i' % samples_b.count(1)) | |
print('[sample_b] 0 => %i' % samples_b.count(0)) | |
print('\n [sample_b] ratio 1/0 => %f' % ( | |
float(samples_b.count(1)) / samples_b.count(0))) | |
print('-'*40) | |
plot_hist(samples_b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment