def sample(counter=simulationCounter): """Sample new Parameter""" alphaNew = prior() # sample from prior """Sample synthetic Data (Beta-coalescent)""" P, q = re.P_and_q_lambda_beta(n_leaves, (alphaNew,)) coalescentNew = lc.simulateLambdaBeta(n_leaves, self.mutationRate, float("inf"), alphaNew, P, q) counter[0] += 1 # increment simulation counter return alphaNew, coalescentNew
Pi_1 = [] Pi_2 = [] coalescentType = coalescentType.lower() print "Running %i simulations of a %s coalescent, with n=%i, theta=%s, alpha=%s, phi=%s..."%(trials,coalescentType,n,str(round(theta,3)),str(round(beta,3)),str(round(psi,3))) t1 = time.time() if coalescentType == 'xi_beta': 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))