示例#1
0
 def _eval_evalf(self, prec):
     from mpmath import mp, workprec
     from sympy import Expr
     a = self.args[0]._to_mpmath(prec)
     z = self.args[1]._to_mpmath(prec)
     with workprec(prec):
         res = mp.gammainc(a, z, mp.inf)
     return Expr._from_mpmath(res, prec)
示例#2
0
 def _eval_evalf(self, prec):
     from mpmath import mp, workprec
     from ... import Expr
     a = self.args[0]._to_mpmath(prec)
     z = self.args[1]._to_mpmath(prec)
     with workprec(prec):
         res = mp.gammainc(a, z, mp.inf)
     return Expr._from_mpmath(res, prec)
示例#3
0
 def _eval_evalf(self, prec):
     if all(x.is_number for x in self.args):
         a = self.args[0]._to_mpmath(prec)
         z = self.args[1]._to_mpmath(prec)
         with workprec(prec):
             res = mp.gammainc(a, z, mp.inf)
         return Expr._from_mpmath(res, prec)
     return self
示例#4
0
 def _eval_evalf(self, prec):
     from mpmath import mp, workprec
     from sympy import Expr
     if all(x.is_number for x in self.args):
         a = self.args[0]._to_mpmath(prec)
         z = self.args[1]._to_mpmath(prec)
         with workprec(prec):
             res = mp.gammainc(a, 0, z)
         return Expr._from_mpmath(res, prec)
     else:
         return self
示例#5
0
 def _eval_evalf(self, prec):
     from mpmath import mp, workprec
     from sympy import Expr
     if all(x.is_number for x in self.args):
         a = self.args[0]._to_mpmath(prec)
         z = self.args[1]._to_mpmath(prec)
         with workprec(prec):
             res = mp.gammainc(a, 0, z)
         return Expr._from_mpmath(res, prec)
     else:
         return self
示例#6
0
def BoysValue(n, x):
    F = []

    if x == mp.mpf("0"):
        for i in range(0, n+1):
            F.append(mp.mpf(1.0)/(mp.mpf(2.0*i+1)))
    else:
        for i in range(0, n+1):
            N = i+mp.mpf("0.5")
            F.append(mp.gammainc(N, 0, x) * 1.0/(2.0 * mp.power(x, N)))

    return F
示例#7
0
def FixedResGlobal(nsigma):
    n_levels = len(nsigma)
    q_perlevel = np.empty(n_levels, dtype=object)
    for l, lev in enumerate(nsigma):
        q_total = 0
        nQs = len(lev)
        for j, sig in enumerate(lev):
            pval = mp.erfc(abs(sig)/mp.sqrt(2))
            q = -2*mp.log(pval)
            q_total += q
        q_perlevel[l] = [q_total, nQs]

    nsigma_fixedres = np.zeros(n_levels)
    for i, entry in enumerate(q_perlevel):
        qT = entry[0]
        nQ = entry[1]
        Dchi2 = mp.gammainc(nQ, 0, 0.5*qT)/mp.gamma(nQ)
        nsigma_ell = mp.sqrt(2)*mp.erfinv(Dchi2)
        nsigma_fixedres[i] = nsigma_ell
    return nsigma_fixedres
示例#8
0
 def _eval_evalf(self, prec):
     a = self.args[0]._to_mpmath(prec)
     z = self.args[1]._to_mpmath(prec)
     with workprec(prec):
         res = mp.gammainc(a, z, mp.inf)
     return Expr._from_mpmath(res, prec)
示例#9
0
    ocl_function=make_ocl("return sas_gamma(q);", "sas_gamma",
                          ["lib/sas_gamma.c"]),
    limits=(-3.1, 10),
)
add_function(
    name="gammaln(x)",
    mp_function=mp.loggamma,
    np_function=scipy.special.gammaln,
    ocl_function=make_ocl("return sas_gammaln(q);", "sas_gammaln",
                          ["lib/sas_gammainc.c"]),
    #ocl_function=make_ocl("return lgamma(q);", "sas_gammaln"),
)
add_function(
    # Note: "a" is given as A=... on the command line via parse_extra_pars
    name="gammainc(x)",
    mp_function=lambda x, a=A: mp.gammainc(a, a=0, b=x) / mp.gamma(a),
    np_function=lambda x, a=A: scipy.special.gammainc(a, x),
    ocl_function=make_ocl("return sas_gammainc(%.15g,q);" % A, "sas_gammainc",
                          ["lib/sas_gammainc.c"]),
)
add_function(
    # Note: "a" is given as A=... on the command line via parse_extra_pars
    name="gammaincc(x)",
    mp_function=lambda x, a=A: mp.gammainc(a, a=x, b=mp.inf) / mp.gamma(a),
    np_function=lambda x, a=A: scipy.special.gammaincc(a, x),
    ocl_function=make_ocl("return sas_gammaincc(%.15g,q);" % A,
                          "sas_gammaincc", ["lib/sas_gammainc.c"]),
)
add_function(
    name="erf(x)",
    mp_function=mp.erf,
示例#10
0
 def _eval_evalf(self, prec):
     a = self.args[0]._to_mpmath(prec)
     z = self.args[1]._to_mpmath(prec)
     with workprec(prec):
         res = mp.gammainc(a, z, mp.inf)
     return Expr._from_mpmath(res, prec)