Compare GPs + Plot¶
In [17]:
Copied!
import fastgps
import qmcpy as qp
import numpy as np
import torch
import pandas as pd
from matplotlib import pyplot
import tueplots.figsizes
import fastgps
import qmcpy as qp
import numpy as np
import torch
import pandas as pd
from matplotlib import pyplot
import tueplots.figsizes
In [18]:
Copied!
device = "cpu"
if device!="mps":
torch.set_default_dtype(torch.float64)
device = "cpu"
if device!="mps":
torch.set_default_dtype(torch.float64)
In [19]:
Copied!
colors = ["xkcd:"+color[:-1] for color in pd.read_csv("../../../xkcd_colors.txt",comment="#").iloc[:,0].tolist()][::-1]
colors = ["xkcd:"+color[:-1] for color in pd.read_csv("../../../xkcd_colors.txt",comment="#").iloc[:,0].tolist()][::-1]
True Function¶
In [20]:
Copied!
d = 1
def f_ackley(x, a=20, b=0.2, c=2*np.pi, scaling=32.768):
# https://www.sfu.ca/~ssurjano/ackley.html
assert x.ndim==2
x = 2*scaling*x-scaling
t1 = a*torch.exp(-b*torch.sqrt(torch.mean(x**2,1)))
t2 = torch.exp(torch.mean(torch.cos(c*x),1))
t3 = a+np.exp(1)
y = -t1-t2+t3
return y
d = 1
def f_ackley(x, a=20, b=0.2, c=2*np.pi, scaling=32.768):
# https://www.sfu.ca/~ssurjano/ackley.html
assert x.ndim==2
x = 2*scaling*x-scaling
t1 = a*torch.exp(-b*torch.sqrt(torch.mean(x**2,1)))
t2 = torch.exp(torch.mean(torch.cos(c*x),1))
t3 = a+np.exp(1)
y = -t1-t2+t3
return y
Parameters¶
In [21]:
Copied!
n = 2**2
xticks = torch.linspace(0,1,501,device=device)
yticks = f_ackley(xticks[:,None])
n = 2**2
xticks = torch.linspace(0,1,501,device=device)
yticks = f_ackley(xticks[:,None])
Standard GP¶
In [22]:
Copied!
print(" n = %d"%n)
sgp = fastgps.StandardGP(
qp.KernelGaussian(d,torchify=True,device=device),
qp.DigitalNetB2(d,seed=11),
)
x_next = sgp.get_x_next(n)
y_next = f_ackley(x_next)
sgp.add_y_next(y_next)
sgp.fit()
pmean_std_n,pstd_std_n,q,ci_low_std_n,ci_high_std_n = sgp.post_ci(xticks[:,None])
x_std_n,y_std_n = sgp.x.clone(),sgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(sgp.post_cubature_var(),2*n,sgp.post_cubature_var(n=2*n),4*n,sgp.post_cubature_var(n=4*n)))
print(" n = %d"%n)
sgp = fastgps.StandardGP(
qp.KernelGaussian(d,torchify=True,device=device),
qp.DigitalNetB2(d,seed=11),
)
x_next = sgp.get_x_next(n)
y_next = f_ackley(x_next)
sgp.add_y_next(y_next)
sgp.fit()
pmean_std_n,pstd_std_n,q,ci_low_std_n,ci_high_std_n = sgp.post_ci(xticks[:,None])
x_std_n,y_std_n = sgp.x.clone(),sgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(sgp.post_cubature_var(),2*n,sgp.post_cubature_var(n=2*n),4*n,sgp.post_cubature_var(n=4*n)))
n = 4 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 1.09e+05 | 1.09e+05 | 2.17e+05 | -1.42e+01 5.00e+00 | 2.75e+03 | 2.75e+03 | 5.49e+03 | -4.56e+00 1.00e+01 | 5.20e+01 | 5.20e+01 | 8.64e+01 | 1.02e+01 1.50e+01 | 1.60e+01 | 1.60e+01 | 3.58e+00 | 2.10e+01 2.00e+01 | 1.60e+01 | 1.60e+01 | 3.29e+00 | 2.13e+01 2.50e+01 | 1.59e+01 | 1.59e+01 | 3.68e+00 | 2.09e+01 posterior cubature var: 4.27e-01 n=8: 1.28e-03 n=16: 1.12e-05
In [23]:
Copied!
print(" n = %d"%(2*n))
x_next = sgp.get_x_next(2*n)
y_next = f_ackley(x_next)
sgp.add_y_next(y_next)
sgp.fit()
pmean_std_2n,pstd_std_2n,q,ci_low_std_2n,ci_high_std_2n = sgp.post_ci(xticks[:,None])
x_std_2n,y_std_2n = sgp.x.clone(),sgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(sgp.post_cubature_var(),4*n,sgp.post_cubature_var(n=4*n),8*n,sgp.post_cubature_var(n=8*n)))
print(" n = %d"%(2*n))
x_next = sgp.get_x_next(2*n)
y_next = f_ackley(x_next)
sgp.add_y_next(y_next)
sgp.fit()
pmean_std_2n,pstd_std_2n,q,ci_low_std_2n,ci_high_std_2n = sgp.post_ci(xticks[:,None])
x_std_2n,y_std_2n = sgp.x.clone(),sgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(sgp.post_cubature_var(),4*n,sgp.post_cubature_var(n=4*n),8*n,sgp.post_cubature_var(n=8*n)))
n = 8 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 2.36e+02 | 2.36e+02 | 4.40e+02 | 1.70e+01 5.00e+00 | 2.71e+01 | 2.73e+01 | 4.10e+00 | 3.58e+01 1.00e+01 | 2.67e+01 | 2.67e+01 | 5.68e+00 | 3.30e+01 1.50e+01 | 2.65e+01 | 2.65e+01 | 6.82e+00 | 3.15e+01 2.00e+01 | 2.65e+01 | 2.65e+01 | 7.54e+00 | 3.07e+01 2.50e+01 | 2.65e+01 | 2.65e+01 | 8.23e+00 | 3.00e+01 3.00e+01 | 2.65e+01 | 2.65e+01 | 8.03e+00 | 3.02e+01 3.20e+01 | 2.65e+01 | 2.65e+01 | 7.95e+00 | 3.03e+01 posterior cubature var: 7.28e-02 n=16: 5.32e-05 n=32: 3.18e-06
In [24]:
Copied!
print(" n = %d"%(4*n))
x_next = sgp.get_x_next(4*n)
assert x_next.shape==(2*n,1)
y_next = f_ackley(x_next)
sgp.add_y_next(y_next)
sgp.fit()
pmean_std_4n,pstd_std_4n,q,ci_low_std_4n,ci_high_std_4n = sgp.post_ci(xticks[:,None])
x_std_4n,y_std_4n = sgp.x.clone(),sgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(sgp.post_cubature_var(),8*n,sgp.post_cubature_var(n=8*n),16*n,sgp.post_cubature_var(n=16*n)))
print(" n = %d"%(4*n))
x_next = sgp.get_x_next(4*n)
assert x_next.shape==(2*n,1)
y_next = f_ackley(x_next)
sgp.add_y_next(y_next)
sgp.fit()
pmean_std_4n,pstd_std_4n,q,ci_low_std_4n,ci_high_std_4n = sgp.post_ci(xticks[:,None])
x_std_4n,y_std_4n = sgp.x.clone(),sgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(sgp.post_cubature_var(),8*n,sgp.post_cubature_var(n=8*n),16*n,sgp.post_cubature_var(n=16*n)))
n = 16 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 1.32e+04 | 1.32e+04 | 2.64e+04 | -2.59e+00 5.00e+00 | 5.66e+01 | 5.66e+01 | 6.43e+00 | 7.74e+01 1.00e+01 | 5.46e+01 | 5.46e+01 | 1.08e+01 | 6.91e+01 1.50e+01 | 5.41e+01 | 5.43e+01 | 1.29e+01 | 6.62e+01 2.00e+01 | 5.41e+01 | 5.41e+01 | 1.54e+01 | 6.34e+01 2.40e+01 | 5.41e+01 | 5.41e+01 | 1.61e+01 | 6.27e+01 posterior cubature var: 1.67e-02 n=32: 1.10e-05 n=64: 1.60e-06
Lattice¶
In [25]:
Copied!
print(" n = %d"%n)
fgp = fastgps.FastGPLattice(
qp.KernelShiftInvar(d,torchify=True,device=device),
qp.Lattice(d,seed=7),
)
x_next = fgp.get_x_next(n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_lattice_n,pstd_lattice_n,q,ci_low_lattice_n,ci_high_lattice_n = fgp.post_ci(xticks[:,None])
x_lattice_n,y_lattice_n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),2*n,fgp.post_cubature_var(n=2*n),4*n,fgp.post_cubature_var(n=4*n)))
print(" n = %d"%n)
fgp = fastgps.FastGPLattice(
qp.KernelShiftInvar(d,torchify=True,device=device),
qp.Lattice(d,seed=7),
)
x_next = fgp.get_x_next(n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_lattice_n,pstd_lattice_n,q,ci_low_lattice_n,ci_high_lattice_n = fgp.post_ci(xticks[:,None])
x_lattice_n,y_lattice_n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),2*n,fgp.post_cubature_var(n=2*n),4*n,fgp.post_cubature_var(n=4*n)))
n = 4 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 2.13e+02 | 2.13e+02 | 4.15e+02 | 3.52e+00 5.00e+00 | 9.45e+01 | 9.45e+01 | 1.73e+02 | 8.74e+00 1.00e+01 | 2.58e+01 | 2.58e+01 | 2.24e+01 | 2.18e+01 1.50e+01 | 1.82e+01 | 1.82e+01 | 4.21e+00 | 2.48e+01 2.00e+01 | 1.56e+01 | 1.56e+01 | 5.28e+00 | 1.86e+01 2.50e+01 | 1.56e+01 | 1.56e+01 | 4.81e+00 | 1.90e+01 3.00e+01 | 1.55e+01 | 1.55e+01 | 3.97e+00 | 1.97e+01 3.50e+01 | 1.55e+01 | 1.55e+01 | 4.44e+00 | 1.92e+01 4.00e+01 | 1.55e+01 | 1.55e+01 | 4.08e+00 | 1.95e+01 4.50e+01 | 1.55e+01 | 1.55e+01 | 4.18e+00 | 1.94e+01 4.80e+01 | 1.54e+01 | 1.54e+01 | 4.07e+00 | 1.95e+01 posterior cubature var: 2.57e-01 n=8: 1.61e-02 n=16: 1.01e-03
In [26]:
Copied!
print(" n = %d"%(2*n))
x_next = fgp.get_x_next(2*n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_lattice_2n,pstd_lattice_2n,q,ci_low_lattice_2n,ci_high_lattice_2n = fgp.post_ci(xticks[:,None])
x_lattice_2n,y_lattice_2n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),4*n,fgp.post_cubature_var(n=4*n),8*n,fgp.post_cubature_var(n=8*n)))
print(" n = %d"%(2*n))
x_next = fgp.get_x_next(2*n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_lattice_2n,pstd_lattice_2n,q,ci_low_lattice_2n,ci_high_lattice_2n = fgp.post_ci(xticks[:,None])
x_lattice_2n,y_lattice_2n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),4*n,fgp.post_cubature_var(n=4*n),8*n,fgp.post_cubature_var(n=8*n)))
n = 8 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 2.45e+01 | 2.45e+01 | 6.82e+00 | 2.74e+01 5.00e+00 | 2.44e+01 | 2.44e+01 | 7.73e+00 | 2.63e+01 1.00e+01 | 2.44e+01 | 2.44e+01 | 7.85e+00 | 2.62e+01 1.10e+01 | 2.44e+01 | 2.44e+01 | 7.92e+00 | 2.61e+01 posterior cubature var: 1.34e-02 n=16: 8.38e-04 n=32: 5.24e-05
In [27]:
Copied!
print(" n = %d"%(4*n))
x_next = fgp.get_x_next(4*n)
assert x_next.shape==(2*n,1)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_lattice_4n,pstd_lattice_4n,q,ci_low_lattice_4n,ci_high_lattice_4n = fgp.post_ci(xticks[:,None])
x_lattice_4n,y_lattice_4n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),8*n,fgp.post_cubature_var(n=8*n),16*n,fgp.post_cubature_var(n=16*n)))
print(" n = %d"%(4*n))
x_next = fgp.get_x_next(4*n)
assert x_next.shape==(2*n,1)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_lattice_4n,pstd_lattice_4n,q,ci_low_lattice_4n,ci_high_lattice_4n = fgp.post_ci(xticks[:,None])
x_lattice_4n,y_lattice_4n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),8*n,fgp.post_cubature_var(n=8*n),16*n,fgp.post_cubature_var(n=16*n)))
n = 16 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 4.79e+01 | 4.79e+01 | 4.26e+01 | 2.38e+01 5.00e+00 | 4.24e+01 | 4.24e+01 | 1.48e+01 | 4.05e+01 1.00e+01 | 4.23e+01 | 4.24e+01 | 1.46e+01 | 4.08e+01 1.40e+01 | 4.23e+01 | 4.23e+01 | 1.58e+01 | 3.95e+01 posterior cubature var: 2.30e-03 n=32: 1.44e-04 n=64: 8.97e-06
Digital Net¶
In [28]:
Copied!
print(" n = %d"%n)
fgp = fastgps.FastGPDigitalNetB2(
qp.KernelDigShiftInvar(d,torchify=True,device=device),
qp.DigitalNetB2(d,seed=7),
)
x_next = fgp.get_x_next(n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_dnb2_n,pstd_dnb2_n,q,ci_low_dnb2_n,ci_high_dnb2_n = fgp.post_ci(xticks[:,None])
x_dnb2_n,y_dnb2_n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),2*n,fgp.post_cubature_var(n=2*n),4*n,fgp.post_cubature_var(n=4*n)))
print(" n = %d"%n)
fgp = fastgps.FastGPDigitalNetB2(
qp.KernelDigShiftInvar(d,torchify=True,device=device),
qp.DigitalNetB2(d,seed=7),
)
x_next = fgp.get_x_next(n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_dnb2_n,pstd_dnb2_n,q,ci_low_dnb2_n,ci_high_dnb2_n = fgp.post_ci(xticks[:,None])
x_dnb2_n,y_dnb2_n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),2*n,fgp.post_cubature_var(n=2*n),4*n,fgp.post_cubature_var(n=4*n)))
n = 4 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 1.70e+02 | 1.70e+02 | 3.30e+02 | 2.85e+00 5.00e+00 | 6.55e+01 | 6.55e+01 | 1.15e+02 | 8.25e+00 1.00e+01 | 1.77e+01 | 1.77e+01 | 5.92e+00 | 2.22e+01 1.50e+01 | 1.77e+01 | 1.79e+01 | 6.60e+00 | 2.17e+01 2.00e+01 | 1.76e+01 | 1.77e+01 | 4.94e+00 | 2.30e+01 2.50e+01 | 1.76e+01 | 1.76e+01 | 3.89e+00 | 2.40e+01 3.00e+01 | 1.75e+01 | 1.75e+01 | 4.92e+00 | 2.28e+01 3.50e+01 | 1.73e+01 | 1.73e+01 | 4.83e+00 | 2.25e+01 4.00e+01 | 1.68e+01 | 1.68e+01 | 4.31e+00 | 2.20e+01 4.50e+01 | 1.54e+01 | 1.54e+01 | 5.02e+00 | 1.85e+01 5.00e+01 | 1.49e+01 | 1.49e+01 | 4.15e+00 | 1.82e+01 5.50e+01 | 1.48e+01 | 1.49e+01 | 3.48e+00 | 1.89e+01 6.00e+01 | 1.48e+01 | 1.49e+01 | 3.81e+00 | 1.85e+01 posterior cubature var: 6.62e+00 n=8: 1.60e+00 n=16: 3.89e-01
In [29]:
Copied!
print(" n = %d"%(2*n))
x_next = fgp.get_x_next(2*n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_dnb2_2n,pstd_dnb2_2n,q,ci_low_dnb2_2n,ci_high_dnb2_2n = fgp.post_ci(xticks[:,None])
x_dnb2_2n,y_dnb2_2n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),4*n,fgp.post_cubature_var(n=4*n),8*n,fgp.post_cubature_var(n=8*n)))
print(" n = %d"%(2*n))
x_next = fgp.get_x_next(2*n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_dnb2_2n,pstd_dnb2_2n,q,ci_low_dnb2_2n,ci_high_dnb2_2n = fgp.post_ci(xticks[:,None])
x_dnb2_2n,y_dnb2_2n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),4*n,fgp.post_cubature_var(n=4*n),8*n,fgp.post_cubature_var(n=8*n)))
n = 8 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 2.92e+01 | 2.92e+01 | 1.11e+01 | 3.26e+01 5.00e+00 | 2.89e+01 | 2.89e+01 | 8.15e+00 | 3.50e+01 1.00e+01 | 2.89e+01 | 2.89e+01 | 8.02e+00 | 3.52e+01 1.10e+01 | 2.89e+01 | 2.89e+01 | 7.88e+00 | 3.53e+01 posterior cubature var: 2.29e+00 n=16: 5.56e-01 n=32: 3.91e-01
In [30]:
Copied!
print(" n = %d"%(4*n))
x_next = fgp.get_x_next(4*n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_dnb2_4n,pstd_dnb2_4n,q,ci_low_dnb2_4n,ci_high_dnb2_4n = fgp.post_ci(xticks[:,None])
x_dnb2_4n,y_dnb2_4n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),8*n,fgp.post_cubature_var(n=8*n),16*n,fgp.post_cubature_var(n=16*n)))
print(" n = %d"%(4*n))
x_next = fgp.get_x_next(4*n)
y_next = f_ackley(x_next)
fgp.add_y_next(y_next)
fgp.fit()
pmean_dnb2_4n,pstd_dnb2_4n,q,ci_low_dnb2_4n,ci_high_dnb2_4n = fgp.post_ci(xticks[:,None])
x_dnb2_4n,y_dnb2_4n = fgp.x.clone(),fgp.y.clone()
print(" posterior cubature var: %-10.2e n=%d: %-10.2e n=%d: %-10.2e"%\
(fgp.post_cubature_var(),8*n,fgp.post_cubature_var(n=8*n),16*n,fgp.post_cubature_var(n=16*n)))
n = 16 iter of 5.0e+03 | best loss | loss | term1 | term2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.00e+00 | 5.13e+01 | 5.13e+01 | 9.27e+00 | 6.39e+01 5.00e+00 | 5.02e+01 | 5.02e+01 | 1.62e+01 | 5.49e+01 1.00e+01 | 5.02e+01 | 5.02e+01 | 1.60e+01 | 5.51e+01 1.50e+01 | 5.02e+01 | 5.02e+01 | 1.61e+01 | 5.50e+01 posterior cubature var: 3.11e-01 n=32: 2.19e-01 n=64: 9.92e-03
Collect Data + Plot¶
In [31]:
Copied!
data = [
[
(x_std_n,y_std_n,pmean_std_n,ci_low_std_n,ci_high_std_n),
(x_lattice_n,y_lattice_n,pmean_lattice_n,ci_low_lattice_n,ci_high_lattice_n),
(x_dnb2_n,y_dnb2_n,pmean_dnb2_n,ci_low_dnb2_n,ci_high_dnb2_n)
],
[
(x_std_2n,y_std_2n,pmean_std_2n,ci_low_std_2n,ci_high_std_2n),
(x_lattice_2n,y_lattice_2n,pmean_lattice_2n,ci_low_lattice_2n,ci_high_lattice_2n),
(x_dnb2_2n,y_dnb2_2n,pmean_dnb2_2n,ci_low_dnb2_2n,ci_high_dnb2_2n)
],
[
(x_std_4n,y_std_4n,pmean_std_4n,ci_low_std_4n,ci_high_std_4n),
(x_lattice_4n,y_lattice_4n,pmean_lattice_4n,ci_low_lattice_4n,ci_high_lattice_4n),
(x_dnb2_4n,y_dnb2_4n,pmean_dnb2_4n,ci_low_dnb2_4n,ci_high_dnb2_4n)
],
]
data = [
[
(x_std_n,y_std_n,pmean_std_n,ci_low_std_n,ci_high_std_n),
(x_lattice_n,y_lattice_n,pmean_lattice_n,ci_low_lattice_n,ci_high_lattice_n),
(x_dnb2_n,y_dnb2_n,pmean_dnb2_n,ci_low_dnb2_n,ci_high_dnb2_n)
],
[
(x_std_2n,y_std_2n,pmean_std_2n,ci_low_std_2n,ci_high_std_2n),
(x_lattice_2n,y_lattice_2n,pmean_lattice_2n,ci_low_lattice_2n,ci_high_lattice_2n),
(x_dnb2_2n,y_dnb2_2n,pmean_dnb2_2n,ci_low_dnb2_2n,ci_high_dnb2_2n)
],
[
(x_std_4n,y_std_4n,pmean_std_4n,ci_low_std_4n,ci_high_std_4n),
(x_lattice_4n,y_lattice_4n,pmean_lattice_4n,ci_low_lattice_4n,ci_high_lattice_4n),
(x_dnb2_4n,y_dnb2_4n,pmean_dnb2_4n,ci_low_dnb2_4n,ci_high_dnb2_4n)
],
]
In [32]:
Copied!
nrows = 3
ncols = len(data[0])
_alpha = 0.25
pyplot.rcParams.update(tueplots.figsizes.icml2024_full(nrows=nrows,ncols=ncols))
fig,ax = pyplot.subplots(nrows=nrows,ncols=ncols)
ax = ax.reshape((nrows,ncols))
for i in range(3):
for j in range(ncols):
x,y,pmean,ci_low,ci_high = data[i][j]
ax[i,j].plot(xticks.cpu(),yticks.cpu(),color="k")
ax[i,j].scatter(x[:,0].cpu(),y.cpu(),color="k")
ax[i,j].plot(xticks.cpu(),pmean.cpu(),color=colors[j])
ax[i,j].fill_between(xticks.cpu(),ci_low.cpu(),ci_high.cpu(),color=colors[j],alpha=_alpha)
ax[0,0].set_title("StandardGP")
ax[0,1].set_title("FastGPDigitalNetB2")
ax[0,2].set_title("FastGPLattice")
ax[0,0].set_ylabel(r"n = %d"%n)
ax[1,0].set_ylabel(r"n = %d"%(2*n))
ax[2,0].set_ylabel(r"n = %d"%(4*n))
fig.savefig("./gps.pdf")
nrows = 3
ncols = len(data[0])
_alpha = 0.25
pyplot.rcParams.update(tueplots.figsizes.icml2024_full(nrows=nrows,ncols=ncols))
fig,ax = pyplot.subplots(nrows=nrows,ncols=ncols)
ax = ax.reshape((nrows,ncols))
for i in range(3):
for j in range(ncols):
x,y,pmean,ci_low,ci_high = data[i][j]
ax[i,j].plot(xticks.cpu(),yticks.cpu(),color="k")
ax[i,j].scatter(x[:,0].cpu(),y.cpu(),color="k")
ax[i,j].plot(xticks.cpu(),pmean.cpu(),color=colors[j])
ax[i,j].fill_between(xticks.cpu(),ci_low.cpu(),ci_high.cpu(),color=colors[j],alpha=_alpha)
ax[0,0].set_title("StandardGP")
ax[0,1].set_title("FastGPDigitalNetB2")
ax[0,2].set_title("FastGPLattice")
ax[0,0].set_ylabel(r"n = %d"%n)
ax[1,0].set_ylabel(r"n = %d"%(2*n))
ax[2,0].set_ylabel(r"n = %d"%(4*n))
fig.savefig("./gps.pdf")