Exemplo n.º 1
0
def generate_argmin_posterior(post_mean, post_covariance, sample_size):
    sample = np.empty((sample_size, D))
    unscaled_grid = unscale(grid, GP_model.FP.X_nonscaled)
    for i in range(0, sample_size):
        f_values = list(
            np.random.multivariate_normal(post_mean,
                                          post_covariance))  #predict/sample GP
        argmax = unscaled_grid[np.where(
            f_values == np.max(f_values))[0], :]  #or unsclae grid before?
        sample[i] = list(argmax[0])
    return (sample)
Exemplo n.º 2
0
            grid = np.vstack([grid1.ravel(), grid2.ravel()])
        else:
            grid = np.vstack([grid, grid2.ravel()])
    return (grid.T)


grid = create_grid(grid_x1, grid_x2, grid_x3, grid_x4, grid_x5, grid_x6)
del grid_x1, grid_x2, grid_x3, grid_x4, grid_x5, grid_x6
''' Slices plots of the posterior mean'''
slice_1_dim = 4
slice_2_dim = 5
fig = plt.figure()
ax = plt.axes(projection="3d")
ax.view_init(elev=90, azim=-90)
f_postmean = GP_model.mu_Sigma_pred(grid)[0]
unscaled_grid = unscale(grid, GP_model.FP.X_nonscaled)
ax.scatter3D(unscaled_grid[:, slice_1_dim - 1],
             unscaled_grid[:, slice_2_dim - 1],
             f_postmean,
             c=f_postmean,
             cmap='hsv')
ax.set_xlabel("\u03B1")
ax.set_ylabel("\u03B2")
plt.title('\u03BC($\mathbf{x}$)')
plt.show()
print(unscaled_grid[:, [slice_1_dim - 1, slice_2_dim -
                        1]][np.where(f_postmean == np.max(f_postmean))[0], :])
''' ------------------------------------------'''
''' Generate Argmin-distribution '''