Python, Monte Carlo, Monte Carlo Simulation, Importance Sampling, Machine Learning.
let’s sample from q(x) and see how it performs: value_list = [] for i in range(n): # sample from different distribution x_i = np.random.normal(mu_appro, sigma_appro) value = f_x(x_i)*(p_x.pdf(x_i) / q_x.pdf(x_i)) value_list.append(value) Notice that here x_i is sampled from the approximate