Exemple #1
0
def fisher_information(kA):
    dx_dt = abc.dx_dt # simplest system with hopf bifurcation
    ka_range = np.linspace(2, 3.8, 19)
    datasets = []
    N = len(ka_range)
    h = 0.01
    #produce all observable datasets into D
    for ka in ka_range:
        datasets.append(abc.generate_dataset_full(dx_dt, [ka]))

    sum_partial = 0.
    for dataset in datasets:
        partial_deriv = (log_likelihood(dataset, abc.generate_dataset_full(dx_dt, [kA + h])) -
                         log_likelihood(dataset, abc.generate_dataset_full(dx_dt, [kA])))
        
        sum_partial += partial_deriv**2

    fi  = sum_partial/(4*N*h**2)
    return fi
Exemple #2
0
def main():
    theta = [2.4, 0.02, 0.2, 6.9]
    M0 = np.array([2.0, 5.0, 3.0])
    ds = abc.generate_dataset_full(hes1, theta)
    noisy_ds = abc.add_gaussian_noise_full(np.copy(ds))
    populations = (abc.smc(hes1, noisy_ds, [300.0]))
    sys.exit(0)
    plt.plot(t, p1, 'r-')
    plt.plot(t, p11, 'b-')
    plt.subplot(313)
    plt.plot(t, p2, 'r-')
    plt.plot(t, p21, 'b-')
    plt.show()
Exemple #3
0
def main():
    theta = [2.4, 0.02, 0.2, 6.9 ]
    M0 = np.array([2.0, 5.0, 3.0])
    ds = abc.generate_dataset_full(hes1, theta)
    noisy_ds = abc.add_gaussian_noise_full(np.copy(ds))
    populations = (abc.smc(hes1, noisy_ds, [300.0]))
    sys.exit(0)
    plt.plot(t, p1,'r-')
    plt.plot(t, p11,'b-')
    plt.subplot(313)
    plt.plot(t, p2,'r-')
    plt.plot(t, p21,'b-')
    plt.show()
Exemple #4
0
def gene_regulation():
    theta = [1., 10.]
    t = np.arange(0, 15, 0.1)
    X0 = 1.
    ds = abc.generate_dataset_full(gene_reg, theta)
    noisy_ds = abc.add_gaussian_noise_full(np.copy(ds))
    populations = abc.smc(gene_reg, noisy_ds, [300.0])
    theta1 = utils.colMeans(np.vstack(populations[:-1]))
    X = integrate.odeint(gene_reg, X0, t, args=(theta, ))
    plt.plot(t, X, 'r-')
    X1 = integrate.odeint(gene_reg, X0, t, args=(theta1, ))
    plt.plot(t, X1, 'b-')
    plt.plot(t, noisy_ds, 'go')
    plt.show()
Exemple #5
0
def gene_regulation():
    theta = [1., 10.]
    t = np.arange(0, 15, 0.1)
    X0 = 1.
    ds = abc.generate_dataset_full(gene_reg, theta)
    noisy_ds = abc.add_gaussian_noise_full(np.copy(ds))
    populations = abc.smc(gene_reg, noisy_ds, [300.0])
    theta1 = utils.colMeans(np.vstack(populations[:-1]))
    X = integrate.odeint(gene_reg, X0, t, args=(theta, ))
    plt.plot(t, X, 'r-')
    X1 = integrate.odeint(gene_reg, X0, t, args=(theta1, ))
    plt.plot(t, X1, 'b-')
    plt.plot(t, noisy_ds, 'go')
    plt.show()
Exemple #6
0
def main_hopf():
    dx_dt = abc.dx_dt # simplest system with hopf bifurcation
    orig_theta = [2.2, 1.]
    orig_ds = abc.generate_dataset_full(dx_dt, orig_theta)
    #orig_ds = abc.add_gaussian_noise_full(orig_ds)
    param_range = np.arange(.5, 7., 0.2)
    param_range_1 = np.arange(4, 7, 0.2)
    likelihood_vals = np.zeros((len(param_range), len(param_range_1)))
    for ind1, th in enumerate(param_range):
        for ind2, th1 in enumerate(param_range_1):
            
            sim_ds = abc.generate_dataset_full(dx_dt, [th, th1])
            l = log_likelihood(sim_ds, orig_ds)
            likelihood_vals[ind1, ind2] = l 
            print th, th1, l

    print "========================"
    i,j = np.unravel_index(likelihood_vals.argmax(), likelihood_vals.shape)
    print "max likelihood ", likelihood_vals[i, j], " at: ()",  i, " ,", j, ")"
    
    fig = plt.figure()
    ax = fig.gca(projection='3d')

    m1, m2 = np.meshgrid(param_range, param_range_1)
    print np.shape(m1), np.shape(m2), np.shape(likelihood_vals)
    surf = ax.plot_surface(m1, m2, likelihood_vals.T, rstride=1,  cstride=1, cmap=cm.jet, linewidth=0.1, antialiased=True)


    fig.colorbar(surf, shrink=0.5, aspect=5)
    
    ax.set_xlabel('kA')
    ax.set_ylabel('k2')
    ax.set_zlabel('likelihood')
    plt.figure()
    plt.imshow(likelihood_vals)
    plt.show()