本文整理匯總了Python中sympy.mpmath.mp.inf方法的典型用法代碼示例。如果您正苦於以下問題:Python mp.inf方法的具體用法?Python mp.inf怎麽用?Python mp.inf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sympy.mpmath.mp
的用法示例。
在下文中一共展示了mp.inf方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _compute_delta
# 需要導入模塊: from sympy.mpmath import mp [as 別名]
# 或者: from sympy.mpmath.mp import inf [as 別名]
def _compute_delta(log_moments, eps):
"""Compute delta for given log_moments and eps.
Args:
log_moments: the log moments of privacy loss, in the form of pairs
of (moment_order, log_moment)
eps: the target epsilon.
Returns:
delta
"""
min_delta = 1.0
for moment_order, log_moment in log_moments:
if moment_order == 0:
continue
if math.isinf(log_moment) or math.isnan(log_moment):
sys.stderr.write("The %d-th order is inf or Nan\n" % moment_order)
continue
if log_moment < moment_order * eps:
min_delta = min(min_delta,
math.exp(log_moment - moment_order * eps))
return min_delta
示例2: _compute_eps
# 需要導入模塊: from sympy.mpmath import mp [as 別名]
# 或者: from sympy.mpmath.mp import inf [as 別名]
def _compute_eps(log_moments, delta):
"""Compute epsilon for given log_moments and delta.
Args:
log_moments: the log moments of privacy loss, in the form of pairs
of (moment_order, log_moment)
delta: the target delta.
Returns:
epsilon
"""
min_eps = float("inf")
for moment_order, log_moment in log_moments:
if moment_order == 0:
continue
if math.isinf(log_moment) or math.isnan(log_moment):
sys.stderr.write("The %d-th order is inf or Nan\n" % moment_order)
continue
min_eps = min(min_eps, (log_moment - math.log(delta)) / moment_order)
return min_eps
示例3: _to_np_float64
# 需要導入模塊: from sympy.mpmath import mp [as 別名]
# 或者: from sympy.mpmath.mp import inf [as 別名]
def _to_np_float64(v):
if math.isnan(v) or math.isinf(v):
return np.inf
return np.float64(v)
######################
# FLOAT64 ARITHMETIC #
######################
示例4: integral_inf
# 需要導入模塊: from sympy.mpmath import mp [as 別名]
# 或者: from sympy.mpmath.mp import inf [as 別名]
def integral_inf(fn):
integral, _ = integrate.quad(fn, -np.inf, np.inf)
return integral
示例5: integral_inf_mp
# 需要導入模塊: from sympy.mpmath import mp [as 別名]
# 或者: from sympy.mpmath.mp import inf [as 別名]
def integral_inf_mp(fn):
integral, _ = mp.quad(fn, [-mp.inf, mp.inf], error=True)
return integral