Pairwise Distance Correlation (PDC)

import math
import numpy as np

from pyxla import pdc
from pyxla.util import load_data, load_sample
from pyxla.sampling import HilbertCurveSampler
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)]
}

deceptive_sample = {
    "name": "Deceptive",
    "X": HilbertCurveSampler(sample_size=100, dim=1, l_bound=0, u_bound=6),
    "F": lambda x: (0.4 * x - 2) ** 2 if x > 0.625 else (10 * x - 4) ** 2 - 2,
    "V": lambda x: ((0.4 * x - 2) ** 2 if x > 0.625 else (10 * x - 4) ** 2 - 2) - 1
}

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)
load_data(deceptive_sample)
load_data(easom_sample)
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.
WARNING:root:The Hilbert curve with dimension 1 is just a number line. You are sampling around points on a number line.
pdc(sphere_sample)
INFO:root:D file has been loaded to the current sample and is saved to ./Sphere_D.csv
({'pdc_F': np.float64(0.46935449585989447),
  'pdc_V': np.float64(0.4302616497085094),
  'pdc_v0': np.float64(0.4872456835789514),
  'pdc_v1': np.float64(-0.011207162648932614),
  'pdc_f0-rank': np.float64(0.3604900151272647),
  'pdc_v0-rank': np.float64(0.4546050540702496),
  'pdc_v1-rank': np.float64(-0.014791083907741046),
  'pdc_paretoV-rank': np.float64(0.39020687398953807),
  'pdc_Deb-rank': np.float64(0.323495227146719),
  'pdc_paretoFV-rank': np.float64(0.3681692538058263)},
 <Figure size 1500x2000 with 12 Axes>)
../../_images/d429f15169618b03a1c79710b8bc573c308317c652db98b21d67772a8bf10706.png
pdc(deceptive_sample)
INFO:root:D file has been loaded to the current sample and is saved to ./Deceptive_D.csv
({'pdc_F': np.float64(0.6904987213382157),
  'pdc_V': np.float64(0.3969660066660272),
  'pdc_f0-rank': np.float64(0.744867403100002),
  'pdc_v0-rank': np.float64(0.43545564796938496),
  'pdc_Deb-rank': np.float64(0.744867403100002),
  'pdc_paretoFV-rank': np.float64(0.744867403100002)},
 <Figure size 1500x1000 with 6 Axes>)
../../_images/e2d0126f847ab0ad737ee155555b79389a736325d2e06dd58c2c26fd38ce7287.png
pdc(easom_sample)
INFO:root:D file has been loaded to the current sample and is saved to ./Easom_D.csv
({'pdc_F': np.float64(0.22675761252419305),
  'pdc_f0-rank': np.float64(0.19072531025985182)},
 <Figure size 1000x500 with 2 Axes>)
../../_images/a06c19f396e3787b552e2f0799949301873e25a9957149b31016e4652324dbca.png