# Bayesian Estimate for Coin Toss - Team 1

## 1861 days ago by bigdata2016

Using Recursive Bayesian learning to estimate the probability of getting a head in a coin toss

will be used in presentation of chapter 2 of pattern classification textbook (duda, hart, stork)

import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D from numpy import argmax,argmin from sage.plot.scatter_plot import ScatterPlot global n global k global alpha @interact def f(n=slider(0,100, 1, 1, label="number of samples")): P=[(round(random()*100), round(random()*100)) for _ in range(n)] x=matrix(RDF,n,1) nH=0 nT=0 for i in range(n): x[i]=int(P[i]/50) if(x[i]==0): nT=nT+1 else: nH=nH+1 html('%s samples created by Sage randomly. %s are heads, %s are tails.'%(n,nH,nT)) T = RealDistribution('beta', [1+nH, 1+nT]) ################################################## plotting def polynomial(x): return T.distribution_function(x) curve=plot(polynomial,(0, 1)) show(curve)

number of samples

## Click to the left again to hide and once more to show the dynamic interactive window