Example #1
0
def single_trait_sim(par):
    sim = traitsim(h=1,
                   num_iteration=1,
                   num_species=10,
                   gamma1=par[0],
                   gamma_K2=par[0],
                   a=par[1],
                   r=1,
                   theta=0,
                   K=5000,
                   mean_trait=0,
                   dev_trait=20,
                   mean_pop=50,
                   dev_pop=20,
                   num_time=2000,
                   replicate=0)
    return sim
Example #2
0
import numpy as np
from Trait_sim_in_branches_stat import traitsim
from ABC_MCMC import calibrication,MCMC_ABC


# Observation parameters [gamma,a]
par_obs = np.array([0.1,0.1])
# Observation generated
obs = traitsim(h = 1, num_iteration=1,num_species=10,gamma1=par_obs[0],gamma_K2=par_obs[0],a = par_obs[1],r = 1,
                  theta = 0,K = 5000 , mean_trait=0,dev_trait=20,mean_pop=50,dev_pop=20, num_time=2000,replicate=1)


# Calibriation step
cal_size = 20000
priorpar = [0.2,0.5,0.1,0.4]
collection = calibrication(samplesize = cal_size, priorpar = priorpar, obs = obs, mode='nor')
np.savetxt("/home/p274981/Python_p2/calibration2w_3chains.txt",collection)
#collection = np.loadtxt("/home/p274981/Python_p2/testcal.txt")
Example #3
0
a = 0.01
h = 1

# statistics for settings
for gamma1 in gamma_vec:
    count2 = 1
    gamma_K2 = gamma1
    for a in a_vec:
        for num_species in num_species_vec:
            traitdata = traitsim(num_time=num_time,
                                 num_species=num_species,
                                 num_iteration=num_iteration,
                                 gamma1=gamma1,
                                 a=a,
                                 r=r,
                                 K=K,
                                 theta=theta,
                                 mean_trait=0,
                                 dev_trait=10,
                                 mean_pop=50,
                                 dev_pop=10,
                                 gamma_K2=gamma_K2,
                                 h=h)
            fig = drawplot(traitdata=traitdata)
            par = (num_species, num_time, num_iteration, count1, count2)  #
            # detect the current dir
            script_dir = os.path.dirname('__file__')
            results_dir = os.path.join(script_dir, 'resultes/')
            # file names
            name = "species%d-time%d-sim%d-nat%d-com%d-DRvsDK" % par
            file_name = "%s.pdf" % name
            # if dir doesn't exist, create it