def compute_a(sigma, q, lmbd, verbose=False):
    lmbd_int = int(math.ceil(lmbd))
    if (lmbd_int == 0):
        return 1.0
    a_lambda_first_term_exact = 0
    a_lambda_second_term_exact = 0
    for i in range((lmbd_int + 1)):
        coef_i = (scipy.special.binom(lmbd_int, i) * (q ** i))
        (s1, s2) = (0, 0)
        for j in range((i + 1)):
            coef_j = (scipy.special.binom(i, j) * ((- 1) ** (i - j)))
            s1 += (coef_j * np.exp((((j * j) - j) / (2.0 * (sigma ** 2)))))
            s2 += (coef_j * np.exp((((j * j) + j) / (2.0 * (sigma ** 2)))))
        a_lambda_first_term_exact += (coef_i * s1)
        a_lambda_second_term_exact += (coef_i * s2)
    a_lambda_exact = (((1.0 - q) * a_lambda_first_term_exact) + (q * a_lambda_second_term_exact))
    if verbose:
        print('A: by binomial expansion    {} = {} + {}'.format(a_lambda_exact, ((1.0 - q) * a_lambda_first_term_exact), (q * a_lambda_second_term_exact)))
    return _to_np_float64(a_lambda_exact)
def compute_a(sigma, q, lmbd, verbose=False):
    lmbd_int = int(math.ceil(lmbd))
    if (lmbd_int == 0):
        return 1.0
    a_lambda_first_term_exact = 0
    a_lambda_second_term_exact = 0
    for i in range((lmbd_int + 1)):
        coef_i = (scipy.special.binom(lmbd_int, i) * (q ** i))
        (s1, s2) = (0, 0)
        for j in range((i + 1)):
            coef_j = (scipy.special.binom(i, j) * ((- 1) ** (i - j)))
            s1 += (coef_j * np.exp((((j * j) - j) / (2.0 * (sigma ** 2)))))
            s2 += (coef_j * np.exp((((j * j) + j) / (2.0 * (sigma ** 2)))))
        a_lambda_first_term_exact += (coef_i * s1)
        a_lambda_second_term_exact += (coef_i * s2)
    a_lambda_exact = (((1.0 - q) * a_lambda_first_term_exact) + (q * a_lambda_second_term_exact))
    if verbose:
        print('A: by binomial expansion    {} = {} + {}'.format(a_lambda_exact, ((1.0 - q) * a_lambda_first_term_exact), (q * a_lambda_second_term_exact)))
    return _to_np_float64(a_lambda_exact)