本文整理汇总了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