Python mpmath.quad() Examples

The following are 9 code examples of mpmath.quad(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module mpmath , or try the search function .
Example #1
Source File: test_cdflib.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _noncentral_chi_cdf(x, df, nc, dps=None):
    if dps is None:
        dps = mpmath.mp.dps
    x, df, nc = mpmath.mpf(x), mpmath.mpf(df), mpmath.mpf(nc)
    with mpmath.workdps(dps):
        res = mpmath.quad(lambda t: _noncentral_chi_pdf(t, df, nc), [0, x])
        return res 
Example #2
Source File: gaussian_moments.py    From machine-learning-diff-private-federated-learning with Apache License 2.0 5 votes vote down vote up
def integral_inf(fn):
  integral, _ = integrate.quad(fn, -np.inf, np.inf)
  return integral 
Example #3
Source File: gaussian_moments.py    From machine-learning-diff-private-federated-learning with Apache License 2.0 5 votes vote down vote up
def integral_bounded(fn, lb, ub):
  integral, _ = integrate.quad(fn, lb, ub)
  return integral 
Example #4
Source File: gaussian_moments.py    From machine-learning-diff-private-federated-learning with Apache License 2.0 5 votes vote down vote up
def integral_inf_mp(fn):
  integral, _ = mp.quad(fn, [-mp.inf, mp.inf], error=True)
  return integral 
Example #5
Source File: gaussian_moments.py    From machine-learning-diff-private-federated-learning with Apache License 2.0 5 votes vote down vote up
def integral_bounded_mp(fn, lb, ub):
  integral, _ = mp.quad(fn, [lb, ub], error=True)
  return integral 
Example #6
Source File: rdp_accountant_test.py    From privacy with Apache License 2.0 5 votes vote down vote up
def _integral_mp(self, fn, bounds=(-inf, inf)):
    integral, _ = quad(fn, bounds, error=True, maxdegree=8)
    return integral 
Example #7
Source File: rdp_accountant_test.py    From models with Apache License 2.0 5 votes vote down vote up
def _integral_mp(self, fn, bounds=(-mp.inf, mp.inf)):
    integral, _ = mp.quad(fn, bounds, error=True, maxdegree=8)
    return integral 
Example #8
Source File: rdp_accountant_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def _integral_inf_mp(self, fn):
    integral, _ = mp.quad(
        fn, [-mp.inf, mp.inf], error=True,
        maxdegree=7)  # maxdegree = 6 is not enough
    return integral 
Example #9
Source File: rdp_accountant_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def _integral_bounded_mp(self, fn, lb, ub):
    integral, _ = mp.quad(fn, [lb, ub], error=True)
    return integral