def recur_rational_quadratic(x, alpha=0.5, m=1): y = [] try: for x_i in x: z = -x_i / (alpha) fz = hyp2f0(alpha, m / 2, z) ret = 2 * (1. - fz.real) ret = nstr(ret) y.append(float(ret)) except: z = -x / (alpha) fz = hyp2f0(alpha, m / 2, z) ret = 2 * (1. - fz.real) ret = nstr(ret) return float(ret) return np.array(y)
def test_hyp2f0(self): def hyp2f0(a, b, c, x): v, err = sc.hyp2f0(a, b, c, x) if abs(err) > max(1, abs(v)) * 1e-7: return np.nan return v assert_mpmath_equal(hyp2f0, _exception_to_nan(lambda a, b, c, x: mpmath.hyp2f0(a, b, c, x, **HYPERKW)), [Arg(), Arg(), Arg(), Arg()], n=10000)
def recur_rational_quadratic(x, alpha, m): """ :param x: :param alpha: \alpha :param rate: 1/\ell^2 :return: """ z = -x / (alpha) fz = hyp2f0(alpha, m / 2, z) return 2 * (1. - fz.real)
def recur_rational_quadratic(x, sigma2, alpha, rate): """ :param x: :param alpha: \alpha :param rate: 1/\ell^2 :return: """ z = - rate * x / (alpha) fz = hyp2f0(alpha, 0.5, z) return 2 * sigma2 * (1. - fz.real)
def test_hyp2f0(self): def hyp2f0(a, b, c, x): v, err = sc.hyp2f0(a, b, c, x) if abs(err) > max(1, abs(v)) * 1e-7: return np.nan return v assert_mpmath_equal( hyp2f0, _exception_to_nan( lambda a, b, c, x: mpmath.hyp2f0(a, b, c, x, **HYPERKW)), [Arg(), Arg(), Arg(), Arg()], n=10000)
def float_mp_hyp2f0(a1, a2, x): try: return float(mpmath.hyp2f0(a1, a2, x)) except TypeError as e: return numpy.nan