Skip to main content

importance_sample

Function importance_sample 

Source
pub fn importance_sample(_x: f32, f_x: f32, p_x: f32, q_x: f32) -> f32
Expand description

Compute importance sample with weight.

Given a sample from proposal distribution q, compute the weighted sample for estimating E_p[f(X)].

§Arguments

  • x - Sample from proposal q
  • f_x - Value of f at x
  • p_x - Target density p(x)
  • q_x - Proposal density q(x)

§Returns

Weighted sample f(x) * p(x) / q(x)