Example #1
0
                                    log=False)
    print "STD-difference between log and physical space :", np.max(
        np.abs(stdpow_weight - std_weight))
    print ""
    # ---- marginal laws using kappa damping coefficient
    n_inter = 21
    lower = -1.
    upper = 1.
    kappa = 1

    m_center = m_gbest * 0
    pdf_m, n_bin, x_bin = pp.marginal_law(m_grid,
                                          f_grid,
                                          m_center,
                                          ndata,
                                          n_inter=n_inter,
                                          lower=lower,
                                          upper=upper,
                                          kappa=kappa,
                                          rms=True)

    # ---> save m_grid, f_grid, r_grid_error, m_gbest,
    #      f_best, delta_m , xbin, n_bin, pdf_m, m_weight, m_pow
    #      kappa, lower, upper
    if save_netcdf:
        if irun == 0:
            if os.path.isfile(outfile):
                os.remove(outfile)
                print "remove ", outfile
            nc = Dataset(outfile, "w", format='NETCDF4')
            # dimensions: name, size
Example #2
0
  m_grid, f_grid, rgrid_error = pp.regrid(m_near, f_near, delta_m, center=True)
  del m_near, f_near
  print "number of particles in subgrid", "{:e}".format(m_grid.shape[0])
  print "Error in energy minimum after subgrid :", np.min(f_grid) - f_gbest
  print''

  # ---> Xi2 weighted mean model, in log and physical space
  m_weight = pp.weighted_mean(m_grid, f_grid, ndata, kappa=1, rms=True, log=True)

  # ---> Xi2 weighted STD model, in log and physical space
  std_weight = pp.weighted_std(m_weight, m_grid, f_grid, ndata, kappa=1, rms=True, log=True)

  # ---- marginal laws using RMS
  indx = indx + 1
  pdf_m[indx, :, :], n_bin, x_bin = pp.marginal_law(m_grid, f_grid, logrhosynth, ndata,
                                        n_inter=n_inter,lower=lower, upper=upper,
                                        kappa=kappa, rms=True)

# ----------------------------------------------------------------------------
# Norme L2 Error
# | pdf(nruns, iparam) - pdf(irun, ipara)|_2

pdf_error = np.empty(shape=(len(vec_run), nparam))
for irun in range(len(vec_run)):
    pdf_error[irun, :] = np.linalg.norm(pdf_m[irun, :] - pdf_m[-1, :], 2)

plt.figure()
# ---> plot selection
for iparam in range(nparam):
    plt.plot(vec_run, pdf_error[:, iparam])
    plt.xlabel('number of runs')
Example #3
0
                                rms=False,
                                log=False)
print "STD-difference between log and physical space :", np.max(
    np.abs(stdpow_weight - std_weight))

# ---- marginal laws using kappa damping coefficient
n_inter = 21
lower = -1.
upper = 1.
kappa = ndata

pdf_m, n_bin, x_bin = pp.marginal_law(m_grid,
                                      f_grid,
                                      m_gbest,
                                      ndata,
                                      n_inter=n_inter,
                                      lower=lower,
                                      upper=upper,
                                      kappa=kappa,
                                      rms=False)

# ---> save m_grid, f_grid, r_grid_error, m_gbest,
#      f_best, delta_m , xbin, n_bin, pdf_m, m_weight, m_pow
#      kappa, lower, upper
if save_netcdf:
    if os.path.isfile(outfile):
        os.remove(outfile)
        print "remove ", outfile
    nc = Dataset(outfile, "w", format='NETCDF4')
    # dimensions: name, size
    nc.createDimension('popsize', f_grid.shape[0])