%matplotlib inline
data = generate_data(100000)
people = ('(0,0,0)', '(0,0,1)', '(0,1,0)', '(0,1,1)', '(1,0,0)', '(1,0,1)', '(1,1,0)', '(1,1,1)')
get_bin = lambda x, n: x >= 0 and str(bin(x))[2:].zfill(n) or "-" + str(bin(x))[3:].zfill(n)
y_pos = np.arange(len(people))
count = [sum([1 for d in data if map(int, list(get_bin(i, 3))) == list(d)]) for i in range(8)]
error = np.random.rand(len(people))
plt.barh(y_pos, count, xerr=error, align='center', alpha=0.4)
plt.yticks(y_pos, people)
plt.xlabel('Anzahl fur (A, H, B)')
plt.title('Ergebnisse')
plt.show()
from sympy.interactive import printing
printing.init_printing(use_latex=True)
p_1 = (count[0] + count[1])
p_2 = (count[4] + count[5])
p_3 = (count[2] + count[3])
p_4 = (count[6] + count[7])
print(latex("p(H=0|A=0) = %0.2f" % (p_1/float(p_1+p_3))))
print(latex("p(H=0|A=1) = %0.2f" % (p_2/float(p_2+p_4))))
p_1 = (count[0] + count[4])
p_2 = (count[1] + count[5])
p_3 = (count[2] + count[6])
p_4 = (count[3] + count[7])
print(latex("p(H=0|B=0) = %0.2f" % (p_1/float(p_1+p_3))))
print(latex("p(H=0|B=1) = %0.2f" % (p_2/float(p_2+p_4))))