# Zuw,Xuw=base.pcn_unweighted_IS(post,N,beta,sigma_is,x0,1,1,Disp=0) #unweighted Is
    # mean_uw[i,:]=np.mean(Xuw[Burn_in:,:,0],0)
    """
    Weighted

    """

    Zw, Xw, W_IS, _ = base.pcn_weighted_IS(post,
                                           N,
                                           beta_original,
                                           sigma_is,
                                           PRIOR,
                                           x0,
                                           Disp=1,
                                           dim_q=7)  #weighted IS
    yy, ww = base.weight_samples(Xw, W_IS, N_temp=4)
    xx = base.resample_IS(yy, ww, N)
    mean_y[i, :] = np.mean(xx[Burn_in:, :, 0], 0)
    """
    pCN

    """

    # Zpcn,Xrwm=base.pcn(post,N*N_temp,sigma_is[0],x0[:,0],Disp=0) #random walk metropolis
    # mean_r[i,:]=np.mean(Xrwm[N_temp*Burn_in:],0)

name_y = 'results/est_y_' + str(INDICATOR).zfill(2) + '.npy'
name_s = 'results/samp_w_' + str(INDICATOR).zfill(2) + '.npy'

np.save(name_y, mean_y)
Ejemplo n.º 2
0
    Xsd = base.state_dependent_PT(post, N, beta, sigma_is, x0, Ns=1,
                                  Disp=0)  #full vanilla, reversible
    Xptf = base.full_vanilla(post, N, beta, sigma_is, x0, Ns=1,
                             Disp=0)  #full vanilla, reversible
    Xuw = base.unweighted_IS(post, N, beta, sigma_is, x0, 1, 1,
                             Disp=0)  #unweighted Is
    Xw, W_IS, W_IS2 = base.weighted_IS(post,
                                       N,
                                       beta_original,
                                       sigma_is,
                                       x0,
                                       Disp=0)  #weighted IS
    Xrwm = base.rwm(post, N * N_temp, sigma_rwm, x0[:, 0],
                    Disp=0)  #random walk metropolis
    yy, ww = base.weight_samples(Xw, W_IS)
    xx = base.resample_IS(yy, ww, N)

    mean_r[i, :] = np.mean(Xrwm[N_temp * Burn_in:], 0)
    mean_pf[i, :] = np.mean(Xptf[Burn_in:, :, 0], 0)
    mean_sd[i, :] = np.mean(Xsd[Burn_in:, :, 0], 0)

    mean_uw[i, :] = np.mean(Xuw[Burn_in:, :, 0], 0)
    mean_w[i, :] = np.average(yy[Burn_in * math.factorial(N_temp):, :, 0],
                              0,
                              weights=ww[Burn_in * math.factorial(N_temp):])

    mean_y[i, :] = np.mean(xx[Burn_in:, :, 0], 0)

    np.save('mean_r_elliptic_b.npy', mean_r)
    np.save('mean_p_elliptic_b.npy', mean_p)