Objective Distribution (distr_F)

import numpy as np
import math
from matplotlib import rc_file

from pyxla import load_data, distr_f
from pyxla.sampling import HilbertCurveSampler
rc_file('../../../../src/.matplotlibrc')
sphere_sample = {
    "name": "Sphere",
    "X": HilbertCurveSampler(sample_size=100, dim=1, l_bound=-5, u_bound=5, seed=42),
    "F": lambda x: x**2,
    "V": [lambda x: x**2 - 2, lambda x: 8 * math.sin(20 * x)]
}

easom_sample = {
    "name": "Easom",
    "X": HilbertCurveSampler(sample_size=100, dim=2, l_bound=-5, u_bound=5, seed=42),
    "F": lambda X: np.cos(X[0]) * X[1] * np.e**(- (X[0] - np.pi)**2 - (X[1] - np.pi)**2)
}

load_data(sphere_sample) # loaded in-place
load_data(easom_sample) # loaded in-place
feat, plot = distr_f(sphere_sample, title=False)
plot.savefig('distr-f-sphere.pdf', bbox_inches='tight')
feat, plot = distr_f(easom_sample, bins=10, title=False)
plot.savefig('distr-f-easom.pdf', bbox_inches='tight')