def testSampler( N=10 ** 2, n_leaves=100, mutationRate=5.0, epsilon=1.0, prior=priorUniform1to2, pseudometric=L2, obsData=False ): if not obsData: underlyingCoalescent = lc.simulateKingman(n_leaves, mutationRate * 50, float("inf")) # (boost mutationRate) obsData = underlyingCoalescent.coal.computeNormalizedSFS() mySampler = ABC_Sampler(obsData, mutationRate) print "Taking %s posterior samples with epsilon = %s" % (str(N), str(round(epsilon, 3))) t1 = time.time() alphas, data, acceptanceRate = mySampler.samplePosteriorBeta(N, pseudometric, prior, epsilon, n_leaves) t2 = time.time() print "elapsed time = %s sec \n" % (str(round(t2 - t1, 3))) pl.hist(alphas, bins=min(50, max(N / 10, 1))) return alphas, data, acceptanceRate
P,q = re.P_and_q_lambda_beta(n,(beta,)) for i in range(trials): Pi_2.append(lc.simulateLambdaBeta_FourWay(n,theta/2.,T_max,beta,P,q)) elif coalescentType == 'lambda_beta' or coalescentType=='xi_lambda_beta': P,q = re.P_and_q_lambda_beta(n,(beta,)) for i in range(trials): Pi_2.append(lc.simulateLambdaBeta(n,theta/2.,T_max,beta,P,q)) elif coalescentType =='lambda_ew': for i in range(trials): Pi_2.append(lc.simulateLambdaEldonWakely(n,theta/2.,T_max,psi)) elif coalescentType == 'xi_ew': for i in range(trials): Pi_2.append(lc.simulateLambdaEldonWakely_FourWay(n,theta/2.,T_max,psi)) elif coalescentType == 'kingman' or coalescentType == 'xi_kingman': for i in range(trials): Pi_2.append(lc.simulateKingman(n,theta/2.,T_max)) elif coalescentType == 'lambda_pointmass': for i in range(trials): Pi_2.append(lc.simulateLambdaPoint(n,theta/2.,T_max,psi)) elif coalescentType == 'xi_pointmass': for i in range(trials): Pi_2.append(lc.simulateLambdaPoint_FourWay(n,theta/2.,T_max,psi)) t2 = time.time() print "done! elapsed time = %s sec \n"%(str(round(t2-t1,3))) print "computing expected average normalized SFS from recursion equation..." t1 = time.time() if coalescentType in set(['xi_beta','lambda_beta','xi_lambda_beta']): xi,phi,p,g = re.expectedSFS(n,coalescentType,theta,beta) elif coalescentType == 'xi_ew' or coalescentType == 'lambda_ew': xi,phi,p,g = re.expectedSFS(n,coalescentType,theta,c,psi)