def sample_and_log_weights(lnpdf, q_logprob, q_sample, num_samples=100):
    """ sample from distribution and produce importance weights """
    X      = q_sample(num_samples)
    llx_q  = q_logprob(X)
    llx_pi = lnpdf(X, 0)
    lnW    = llx_pi - llx_q
    return X, lnW