Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, c):
Dist.__init__(self, c=c)
def _pdf(self, x, c):
norm = (2*numpy.pi)**-.5*numpy.exp(-x**2/2.)
return c*norm*special.ndtr(-x)**(c-1.)
def _cdf(self, x, c):
return 1.-special.ndtr(-x)**c
def _ppf(self, q, c):
return -special.ndtri(pow(1-q, 1./c))
class PowerNormal(Add):
"""
Power normal or Box-Cox distribution.
Args:
shape (float, Dist):
Shape parameter
mu (float, Dist):
Mean of the normal distribution
scale (float, Dist):
Standard deviation of the normal distribution
Examples:
>>> distribution = chaospy.PowerNormal(2, 2, 2)
>>> distribution
PowerNormal(mu=2, scale=2, shape=2)
>>> q = numpy.linspace(0,1,6)[1:-1]
def __init__(self, loc=0, scale=1):
self._repr = {"loc": loc, "scale": scale}
Add.__init__(self, left=levy()*scale, right=loc)
def __init__(self, shape=1, scale=1, shift=0):
self._repr = {"shape": shape, "scale": scale, "shift": shift}
Add.__init__(self, left=double_gamma(shape)*scale, right=shift)
def _ppf(self, q, a, c):
val1 = special.gammaincinv(a, q)
val2 = special.gammaincinv(a, 1.0-q)
ic = 1.0/c
cond = c+0*val1
return numpy.where(cond > 0, val1**ic, val2**ic)
def _mom(self, k, a, c):
return special.gamma((c+k)*1./a)/special.gamma(c*1./a)
def _lower(self, a, c):
return 0.
class GeneralizedGamma(Add):
"""
Generalized gamma distribution
Args:
shape1 (float, Dist):
Shape parameter 1
shape2 (float, Dist):
Shape parameter 2
scale (float, Dist):
Scaling parameter
shift (float, Dist):
Location parameter
Examples:
>>> distribution = chaospy.GeneralizedGamma(3, 2, 2, 2)
>>> distribution
def __init__(self, shape=1, scale=1, loc=0):
self._repr = {"shape": shape, "scale": scale, "loc": loc}
Add.__init__(self, left=pareto1(shape)*scale, right=loc)
Dist.__init__(self, c=c)
def _pdf(self, x, c):
return numpy.sqrt(2.0/numpy.pi)*numpy.cosh(c*x)*numpy.exp(-(x*x+c*c)/2.0)
def _cdf(self, x, c):
return special.ndtr(x-c) + special.ndtr(x+c) - 1.0
def _lower(self, c):
return 0.
def _upper(self, c):
return 7.5+c
class FoldedNormal(Add):
"""
Folded normal distribution.
Args:
mu (float, Dist):
Location parameter in normal distribution
sigma (float, Dist):
Scaling parameter (in both normal and fold)
loc (float, Dist):
Location of fold
Examples:
>>> distribution = chaospy.FoldedNormal(3, 2, 1)
>>> distribution
FoldedNormal(loc=1, mu=3, sigma=2)
>>> q = numpy.linspace(0, 1, 6)[1:-1]
def __init__(self, shape=1, scale=1, shift=0):
self._repr = {"shape": shape, "scale": scale, "shift": shift}
Add.__init__(self, left=weibull(shape)*scale, right=shift)
"""Log-gamma distribution."""
def __init__(self, c):
Dist.__init__(self, c=c)
def _pdf(self, x, c):
return numpy.exp(c*x-numpy.exp(x)-special.gammaln(c))
def _cdf(self, x, c):
return special.gammainc(c, numpy.exp(x))
def _ppf(self, q, c):
return numpy.log(special.gammaincinv(c,q))
class LogGamma(Add):
"""
Log-gamma distribution
Args:
shape (float, Dist):
Shape parameter
scale (float, Dist):
Scaling parameter
shift (float, Dist):
Location parameter
Examples:
>>> distribution = chaospy.LogGamma(2, 2, 1)
>>> distribution
LogGamma(scale=2, shape=2, shift=1)
>>> q = numpy.linspace(0,1,6)[1:-1]
def __init__(self, shape=1, scale=1, shift=0):
self._repr = {"shape": shape, "scale": scale, "shift": shift}
Add.__init__(self, left=log_gamma(shape)*scale, right=shift)
def __init__(self, shape, scale, shift):
self._repr = {"shape": shape, "scale": scale, "shift": shift}
Add.__init__(self, left=gompertz(shape)*scale, right=shift)