MCPcopy
hub / github.com/GPflow/GPflow / test_log_prior_on_unconstrained

Function test_log_prior_on_unconstrained

tests/gpflow/test_base_prior.py:71–90  ·  view source on GitHub ↗

A parameter with an Exp transform, and a uniform prior on its unconstrained, should have a prior in the constrained space that scales as 1/value.

()

Source from the content-addressed store, hash-verified

69
70
71def test_log_prior_on_unconstrained() -> None:
72 """
73 A parameter with an Exp transform, and a uniform prior on its unconstrained, should have a
74 prior in the constrained space that scales as 1/value.
75 """
76
77 initial_value = 1.0
78 scale_factor = 10.0
79 uniform_prior = Uniform(low=np.float64(0), high=np.float64(100))
80 param = gpflow.Parameter(
81 initial_value,
82 transform=Exp(),
83 prior=uniform_prior,
84 prior_on=PriorOn.UNCONSTRAINED,
85 )
86 low_value = param.log_prior_density().numpy()
87 param.assign(scale_factor * initial_value)
88 high_value = param.log_prior_density().numpy()
89
90 assert np.isclose(low_value, high_value + np.log(scale_factor))
91
92
93class DummyModel(gpflow.models.BayesianModel):

Callers

nothing calls this directly

Calls 2

log_prior_densityMethod · 0.95
assignMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…