def binomial_log_pdf_ddd(k, p, n): from qy.math import ln_choose @qy.if_(k > n) def _(): qy.return_(-numpy.inf) @qy.if_(p == 0.0) def _(): qy.return_(qy.select(k == 0.0, 0.0, -numpy.inf)) @qy.if_(p == 1.0) def _(): qy.return_(qy.select(k == n, 0.0, -numpy.inf)) qy.return_(ln_choose(n, k) + k * qy.log(p) + (n - k) * qy.log1p(-p))
def binomial_log_pdf_ddd(k, p, n): from qy.math import ln_choose @qy.if_(k > n) def _(): qy.return_(-numpy.inf) @qy.if_(p == 0.0) def _(): qy.return_(qy.select(k == 0.0, 0.0, -numpy.inf)) @qy.if_(p == 1.0) def _(): qy.return_(qy.select(k == n, 0.0, -numpy.inf)) qy.return_( ln_choose(n, k) + k * qy.log(p) + (n - k) * qy.log1p(-p))
def _(then): if then: qy.return_(-numpy.inf) else: qy.return_(a + qy.log1p(qy.exp(qy.select(s, y_in, x_in) - a)))
def _(): v0 = qy.log1p(math.e - 1.0) @qy.python(v0) def _(v0_py): assert_equal(v0_py, 1.0)