Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (19 sloc) 563 Bytes
import numpy as np
import matplotlib.pylab as plt
pA,pB,pO=1.0/3,1.0/3,1.0/3
nA,nB,nAB,nO=25,25,50,15
N=nA+nB+nAB+nO
print pA, pB,pO
for i in range(20):
EAA=pA**2*nA/(pA**2+2*pA*pO)
EAO=2*pA*pO*nA/(pA**2+2*pA*pO)
EBB=pB**2*nB/(pB**2+2*pB*pO)
EBO=2*pB*pO*nB/(pB**2+2*pB*pO)
EAB=nAB
EOO=nO
pA=(2*EAA+EAO+EAB)/(2*N)
pB=(2*EBB+EBO+EAB)/(2*N)
pO=(2*EOO+EAO+EBO)/(2*N)
like=nA*np.log(pA**2+2*pA*pO)+nB*np.log(pB**2+2*pB*pO)+nAB*np.log(2*pA*pB)+nO*np.log(pO**2)
print pA, pB,pO,like
print EAA,EAO,EAB,EBB,EBO,EOO
You can’t perform that action at this time.