pub struct MultivariateRatioUniforms<'a> { /* private fields */ }Expand description
The multivariate ratio-of-uniforms method (Wakefield, Gelfand and Smith 1991; the idea of UNU.RAN’s
VNROU) for a unimodal density f on ℝᵈ known up to a constant, with its mode m: if (u, v)
is uniform on {(u, v): 0 < u ≤ f(m + v/u)^{1/(d+1)}}, then m + v/u has density ∝ f. The region
lies in the box [0, f(m)^{1/(d+1)}] × ∏ᵢ [vᵢ⁻, vᵢ⁺] with vᵢ⁺ = sup (xᵢ − mᵢ) f(x)^{1/(d+1)} and
vᵢ⁻ = inf, found at construction by a derivative-free search from several starting points, with a
1 % margin, or given. Points of the box are drawn and kept if they fall in the region. The method is exact when the box
contains the region, and its acceptance rate falls with d (about 27 % for the normal density at
d = 3, 7 % at d = 5).
Implementations§
Source§impl<'a> MultivariateRatioUniforms<'a>
impl<'a> MultivariateRatioUniforms<'a>
Sourcepub fn new(
pdf: impl Fn(&[f64]) -> f64 + 'a,
mode: &[f64],
) -> Result<Self, ErrorsJSL>
pub fn new( pdf: impl Fn(&[f64]) -> f64 + 'a, mode: &[f64], ) -> Result<Self, ErrorsJSL>
pdf (up to a constant) with its mode; the box is found numerically.
Sourcepub fn with_bounds(
pdf: impl Fn(&[f64]) -> f64 + 'a,
mode: &[f64],
vmin: Vec<f64>,
vmax: Vec<f64>,
) -> Result<Self, ErrorsJSL>
pub fn with_bounds( pdf: impl Fn(&[f64]) -> f64 + 'a, mode: &[f64], vmin: Vec<f64>, vmax: Vec<f64>, ) -> Result<Self, ErrorsJSL>
With the box given: vmin[i] ≤ 0 ≤ vmax[i] must contain (xᵢ − mᵢ) f(x)^{1/(d+1)} for every x.
Sourcepub fn acceptance_rate(&self) -> f64
pub fn acceptance_rate(&self) -> f64
The fraction of the points drawn so far that were kept.