3d exponential model
We simulate from a 3d exponential covariance model and estimate its parameters from the simulation
In [1]:
Copied!
# ##Imports
import matplotlib.pyplot as plt
from IPython.display import HTML
from debiased_spatial_whittle.grids.base import RectangularGrid
from debiased_spatial_whittle.inference.likelihood import DebiasedWhittle, Estimator
from debiased_spatial_whittle.models.univariate import (
SquaredExponentialModel,
NuggetModel,
)
from debiased_spatial_whittle.inference.periodogram import Periodogram, ExpectedPeriodogram
from debiased_spatial_whittle.sampling.simulation import SamplerOnRectangularGrid
from debiased_spatial_whittle.utils import video_plot_3d
# ##Imports
import matplotlib.pyplot as plt
from IPython.display import HTML
from debiased_spatial_whittle.grids.base import RectangularGrid
from debiased_spatial_whittle.inference.likelihood import DebiasedWhittle, Estimator
from debiased_spatial_whittle.models.univariate import (
SquaredExponentialModel,
NuggetModel,
)
from debiased_spatial_whittle.inference.periodogram import Periodogram, ExpectedPeriodogram
from debiased_spatial_whittle.sampling.simulation import SamplerOnRectangularGrid
from debiased_spatial_whittle.utils import video_plot_3d
Grid and model specification¶
In [2]:
Copied!
n = (32, 32, 256)
grid = RectangularGrid(n)
n = (32, 32, 256)
grid = RectangularGrid(n)
In [3]:
Copied!
model = SquaredExponentialModel(rho=8.0, sigma=0.8)
model = NuggetModel(model, nugget=0.0001)
# ##Sample generation
model = SquaredExponentialModel(rho=8.0, sigma=0.8)
model = NuggetModel(model, nugget=0.0001)
# ##Sample generation
In [4]:
Copied!
sampler = SamplerOnRectangularGrid(model, grid)
z = sampler()
sampler = SamplerOnRectangularGrid(model, grid)
z = sampler()
-0.016607062739554056 666.8735239303197 up-sampling
In [5]:
Copied!
anim = video_plot_3d(z, get_title=lambda i: "", cmap="Spectral")
plt.close()
HTML(anim.to_jshtml())
anim = video_plot_3d(z, get_title=lambda i: "", cmap="Spectral")
plt.close()
HTML(anim.to_jshtml())
Out[5]:
Inference¶
In [6]:
Copied!
p = Periodogram()
ep = ExpectedPeriodogram(grid, p)
d = DebiasedWhittle(p, ep)
e = Estimator(d, use_gradients=False)
p = Periodogram()
ep = ExpectedPeriodogram(grid, p)
d = DebiasedWhittle(p, ep)
e = Estimator(d, use_gradients=False)
In [7]:
Copied!
model = SquaredExponentialModel(rho=2.0, sigma=1)
model = NuggetModel(model, nugget=0.0001)
model.fix_parameter("nugget")
model = SquaredExponentialModel(rho=2.0, sigma=1)
model = NuggetModel(model, nugget=0.0001)
model.fix_parameter("nugget")
In [8]:
Copied!
def opt_callback(*args, **kargs):
print(*args)
print(**kargs)
def opt_callback(*args, **kargs):
print(*args)
print(**kargs)
In [9]:
Copied!
print("start estimation")
e(model, z, opt_callback=opt_callback)
print("start estimation")
e(model, z, opt_callback=opt_callback)
start estimation
[2.84883191 0.47133716]
[2.88744541 0.7520595 ]
[3.08774994 0.700794 ]
[3.90869887 0.56387576]
[4.38223006 0.61877257]
[5.98810485 0.69755237]
[7.23010894 0.73764452]
[8.19117583 0.75722208]
[8.46434364 0.75751357] [8.5074994 0.75504699]
[8.50348011 0.75266892]
[8.49517128 0.75180883]
[8.49040147 0.75164232]
[8.49040146 0.75164232]
Out[9]:
NuggetModel()
| Name | Value | Type | Range |
|---|---|---|---|
nugget | 0.0001 | ModelParameter | read-only (0, 1) |
SquaredExponentialModel()
| Name | Value | Type | Range |
|---|---|---|---|
rho | 8.490401462049036 | ModelParameter | (0, inf) |
sigma | 0.7516423193467396 | ModelParameter | (0, inf) |