pub struct ImportanceSampler {
pub proposal_sigma: f64,
/* private fields */
}Expand description
Importance sampler with acceptance-rejection and adaptive IS weights.
Uses a proposal distribution q(x) to estimate expectations under target p(x).
Fields§
§proposal_sigma: f64Proposal distribution standard deviation.
Implementations§
Source§impl ImportanceSampler
impl ImportanceSampler
Sourcepub fn accept_reject<F, G>(
&mut self,
target: F,
proposal_sample: G,
c: f64,
) -> f64
pub fn accept_reject<F, G>( &mut self, target: F, proposal_sample: G, c: f64, ) -> f64
Acceptance-rejection sampler for target pdf target with envelope c * proposal.
Returns a sample from the target distribution.
Sourcepub fn importance_weights<F, G>(
&self,
samples: &[f64],
target: F,
proposal: G,
) -> Vec<f64>
pub fn importance_weights<F, G>( &self, samples: &[f64], target: F, proposal: G, ) -> Vec<f64>
Computes unnormalized importance weights for samples drawn from proposal.
w_i = target(x_i) / proposal(x_i).
Auto Trait Implementations§
impl Freeze for ImportanceSampler
impl RefUnwindSafe for ImportanceSampler
impl Send for ImportanceSampler
impl Sync for ImportanceSampler
impl Unpin for ImportanceSampler
impl UnsafeUnpin for ImportanceSampler
impl UnwindSafe for ImportanceSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.