You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WIP: Enable (naive) minibatching within MCMC. (#349)
* start on observation series in Sampler
removed observationseries, implemented a proposal with AdvancedMH.DensityModel that can deal with multiple observed samples
format
test naive sampling
format
* try api docs fix
* try doc fix
* test int data
* typo and format
* relax test that is breaking on borderline
* added note on many samples
* allow mat or vec of vec for samples
* formatting
* fix unit-tests
Copy file name to clipboardExpand all lines: docs/src/sample.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,9 @@ mcmc = MCMCWrapper(
30
30
```
31
31
The keyword arguments `init_params` give a starting step of the chain (often taken to be the mean of the final iteration of calibrate stage), and a `burnin` gives a number of initial steps to be discarded when drawing statistics from the sampling method.
32
32
33
+
!!! note "for many samples"
34
+
If one has several samples of conditionally-independent data (that is, ``p({y_1,\dots,y_n}\mid\theta)`` is a product of ``\prod_i p(y_i\mid\theta)``), then one can feed in `truth_sample` as a vector of these samples, or a matrix with these samples as columns. The resulting sampler will evaluate the likelihood at all `y_i` for every sample step.
35
+
33
36
For good efficiency, one often needs to run MCMC with a problem-dependent step size. We provide a simple utility to help choose this. Here the optimizer runs short chains (of length `N`), and adjusts the step-size until the MCMC acceptance rate falls within an acceptable range, returning this step size.
# Sampler extensions to differentiate vanilla RW and pCN algorithms
72
88
#
@@ -263,6 +279,38 @@ autodiff_hessian(model::AdvancedMH.DensityModel, params, sampler::MH) where {MH
263
279
"""
264
280
$(DocStringExtensions.TYPEDSIGNATURES)
265
281
282
+
Defines the internal log-density function over a vector of observation samples using an assumed conditionally indepedent likelihood, that is with a log-likelihood of `ℓ(y,θ) = sum^n_i log( p(y_i|θ) )`.
283
+
"""
284
+
function emulator_log_density_model(
285
+
θ,
286
+
prior::ParameterDistribution,
287
+
em::Emulator{FT},
288
+
obs_vec::AV,
289
+
) where {FT <:AbstractFloat, AV <:AbstractVector}
290
+
291
+
# θ: model params we evaluate at; in original coords.
292
+
# transform_to_real = false means g, g_cov, obs_sample are in decorrelated coords.
293
+
294
+
# Recall predict() written to return multiple N_samples: expects input to be a
295
+
# Matrix with N_samples columns. Returned g is likewise a Matrix, and g_cov is a
296
+
# Vector of N_samples covariance matrices. For MH, N_samples is always 1, so we
297
+
# have to reshape()/re-cast input/output; simpler to do here than add a
struct MCMCWrapper{AMorAV <:Union{AbstractVector, AbstractMatrix}, AV <:AbstractVector}
520
546
"[`ParameterDistribution`](https://clima.github.io/EnsembleKalmanProcesses.jl/dev/parameter_distributions/) object describing the prior distribution on parameter values."
521
547
prior::ParameterDistribution
548
+
"A vector or [Nx1] matrix, describing a single observation data (or NxM column-matrix / vector or vectors for multiple observations) provided by the user."
549
+
observations::AMorAV
550
+
"Vector of observations describing the data samples to actually used during MCMC sampling (that have been transformed into a space consistent with emulator outputs)."
551
+
decorrelated_observations::AV
522
552
"`AdvancedMH.DensityModel` object, used to evaluate the posterior density being sampled from."
523
553
log_posterior_map::AbstractMCMC.AbstractModel
524
554
"Object describing a MCMC sampling algorithm and its settings."
@@ -556,15 +586,18 @@ decorrelation) that was applied in the Emulator. It creates and wraps an instanc
0 commit comments