|
|
@ -1,5 +1,6 @@
|
|
|
|
from numpy import pi, r_, minimum, maximum, atleast_1d, atleast_2d, mod, ones, floor, \
|
|
|
|
from numpy import (pi, r_, minimum, maximum, atleast_1d, atleast_2d, mod, ones,
|
|
|
|
random, eye, nonzero, where, repeat, sqrt, exp, inf, diag, zeros, sin, arcsin, nan #@UnresolvedImport
|
|
|
|
floor, random, eye, nonzero, where, repeat, sqrt, exp, inf,
|
|
|
|
|
|
|
|
diag, zeros, sin, arcsin, nan) # @UnresolvedImport
|
|
|
|
from numpy import triu # @UnresolvedImport
|
|
|
|
from numpy import triu # @UnresolvedImport
|
|
|
|
from scipy.special import ndtr as cdfnorm, ndtri as invnorm
|
|
|
|
from scipy.special import ndtr as cdfnorm, ndtri as invnorm
|
|
|
|
from scipy.special import erfc
|
|
|
|
from scipy.special import erfc
|
|
|
@ -11,9 +12,12 @@ import warnings
|
|
|
|
from wafo.misc import common_shape
|
|
|
|
from wafo.misc import common_shape
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ['Rind', 'rindmod', 'mvnprdmod', 'mvn', 'cdflomax', 'prbnormtndpc',
|
|
|
|
__all__ = ['Rind', 'rindmod', 'mvnprdmod', 'mvn', 'cdflomax', 'prbnormtndpc',
|
|
|
|
'prbnormndpc', 'prbnormnd', 'cdfnorm2d', 'prbnorm2d','cdfnorm','invnorm',
|
|
|
|
'prbnormndpc', 'prbnormnd', 'cdfnorm2d', 'prbnorm2d', 'cdfnorm',
|
|
|
|
'test_docstring']
|
|
|
|
'invnorm', 'test_docstring']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Rind(object):
|
|
|
|
class Rind(object):
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
RIND Computes multivariate normal expectations
|
|
|
|
RIND Computes multivariate normal expectations
|
|
|
|
|
|
|
|
|
|
|
@ -24,7 +28,8 @@ class Rind(object):
|
|
|
|
m : array-like, size Ntdc
|
|
|
|
m : array-like, size Ntdc
|
|
|
|
expectation of X=[Xt,Xd,Xc]
|
|
|
|
expectation of X=[Xt,Xd,Xc]
|
|
|
|
Blo, Bup : array-like, shape Mb x Nb
|
|
|
|
Blo, Bup : array-like, shape Mb x Nb
|
|
|
|
Lower and upper barriers used to compute the integration limits, Hlo and Hup, respectively.
|
|
|
|
Lower and upper barriers used to compute the integration limits,
|
|
|
|
|
|
|
|
Hlo and Hup, respectively.
|
|
|
|
indI : array-like, length Ni
|
|
|
|
indI : array-like, length Ni
|
|
|
|
vector of indices to the different barriers in the indicator function.
|
|
|
|
vector of indices to the different barriers in the indicator function.
|
|
|
|
(NB! restriction indI(1)=-1, indI(NI)=Nt+Nd, Ni = Nb+1)
|
|
|
|
(NB! restriction indI(1)=-1, indI(NI)=Nt+Nd, Ni = Nb+1)
|
|
|
@ -50,7 +55,7 @@ class Rind(object):
|
|
|
|
"Jacobian" = |X(Nt+1)*...*X(Nt+Nd)|=|Xd(1)*Xd(2)..Xd(Nd)|
|
|
|
|
"Jacobian" = |X(Nt+1)*...*X(Nt+Nd)|=|Xd(1)*Xd(2)..Xd(Nd)|
|
|
|
|
"condition" = Xc=xc(:,ix), ix=1,...,Nx.
|
|
|
|
"condition" = Xc=xc(:,ix), ix=1,...,Nx.
|
|
|
|
X = [Xt, Xd, Xc], a stochastic vector of Multivariate Gaussian
|
|
|
|
X = [Xt, Xd, Xc], a stochastic vector of Multivariate Gaussian
|
|
|
|
variables where Xt,Xd and Xc have the length Nt,Nd and Nc, respectively.
|
|
|
|
variables where Xt,Xd and Xc have the length Nt,Nd and Nc, respectively
|
|
|
|
(Recommended limitations Nx,Nt<=100, Nd<=6 and Nc<=10)
|
|
|
|
(Recommended limitations Nx,Nt<=100, Nd<=6 and Nc<=10)
|
|
|
|
|
|
|
|
|
|
|
|
Multivariate probability is computed if Nd = 0.
|
|
|
|
Multivariate probability is computed if Nd = 0.
|
|
|
@ -126,10 +131,10 @@ class Rind(object):
|
|
|
|
Per A. Brodtkorb (2006)
|
|
|
|
Per A. Brodtkorb (2006)
|
|
|
|
"Evaluating Nearly Singular Multinormal Expectations with Application to
|
|
|
|
"Evaluating Nearly Singular Multinormal Expectations with Application to
|
|
|
|
Wave Distributions",
|
|
|
|
Wave Distributions",
|
|
|
|
Methodology And Computing In Applied Probability, Volume 8, Number 1, pp. 65-91(27)
|
|
|
|
Methodology And Computing In Applied Probability, Volume 8, Number 1,
|
|
|
|
|
|
|
|
pp. 65-91(27)
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, **kwds):
|
|
|
|
def __init__(self, **kwds):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Parameters
|
|
|
|
Parameters
|
|
|
@ -149,25 +154,28 @@ class Rind(object):
|
|
|
|
scales the conditinal probability density, i.e.,
|
|
|
|
scales the conditinal probability density, i.e.,
|
|
|
|
f_{Xc} = exp(-0.5*Xc*inv(Sxc)*Xc + XcScale) (default XcScale=0)
|
|
|
|
f_{Xc} = exp(-0.5*Xc*inv(Sxc)*Xc + XcScale) (default XcScale=0)
|
|
|
|
abseps, releps : real scalars, optional
|
|
|
|
abseps, releps : real scalars, optional
|
|
|
|
absolute and relative error tolerance. (default abseps=0, releps=1e-3)
|
|
|
|
absolute and relative error tolerance.
|
|
|
|
|
|
|
|
(default abseps=0, releps=1e-3)
|
|
|
|
coveps : real scalar, optional
|
|
|
|
coveps : real scalar, optional
|
|
|
|
error tolerance in Cholesky factorization (default 1e-13)
|
|
|
|
error tolerance in Cholesky factorization (default 1e-13)
|
|
|
|
maxpts, minpts : scalar integers, optional
|
|
|
|
maxpts, minpts : scalar integers, optional
|
|
|
|
maximum and minimum number of function values allowed. The parameter,
|
|
|
|
maximum and minimum number of function values allowed. The
|
|
|
|
maxpts, can be used to limit the time. A sensible strategy is to start
|
|
|
|
parameter, maxpts, can be used to limit the time. A sensible
|
|
|
|
with MAXPTS = 1000*N, and then increase MAXPTS if ERROR is too large.
|
|
|
|
strategy is to start with MAXPTS = 1000*N, and then increase MAXPTS
|
|
|
|
|
|
|
|
if ERROR is too large.
|
|
|
|
(Only for METHOD~=0) (default maxpts=40000, minpts=0)
|
|
|
|
(Only for METHOD~=0) (default maxpts=40000, minpts=0)
|
|
|
|
seed : scalar integer, optional
|
|
|
|
seed : scalar integer, optional
|
|
|
|
seed to the random generator used in the integrations
|
|
|
|
seed to the random generator used in the integrations
|
|
|
|
(Only for METHOD~=0)(default floor(rand*1e9))
|
|
|
|
(Only for METHOD~=0)(default floor(rand*1e9))
|
|
|
|
nit : scalar integer, optional
|
|
|
|
nit : scalar integer, optional
|
|
|
|
maximum number of Xt variables to integrate. This parameter can be used
|
|
|
|
maximum number of Xt variables to integrate. This parameter can be
|
|
|
|
to limit the time. If NIT is less than the rank of the covariance matrix,
|
|
|
|
used to limit the time. If NIT is less than the rank of the
|
|
|
|
the returned result is a upper bound for the true value of the integral.
|
|
|
|
covariance matrix, the returned result is a upper bound for the
|
|
|
|
(default 1000)
|
|
|
|
true value of the integral. (default 1000)
|
|
|
|
xcutoff : real scalar, optional
|
|
|
|
xcutoff : real scalar, optional
|
|
|
|
cut off value where the marginal normal distribution is truncated.
|
|
|
|
cut off value where the marginal normal distribution is truncated.
|
|
|
|
(Depends on requested accuracy. A value between 4 and 5 is reasonable.)
|
|
|
|
(Depends on requested accuracy. A value between 4 and 5 is
|
|
|
|
|
|
|
|
reasonable.)
|
|
|
|
xsplit : real scalar
|
|
|
|
xsplit : real scalar
|
|
|
|
parameter controlling performance of quadrature integration:
|
|
|
|
parameter controlling performance of quadrature integration:
|
|
|
|
if Hup>=xCutOff AND Hlo<-XSPLIT OR
|
|
|
|
if Hup>=xCutOff AND Hlo<-XSPLIT OR
|
|
|
@ -187,8 +195,8 @@ class Rind(object):
|
|
|
|
XCUTOFF, MAXPTS and QUADNO will be set according to
|
|
|
|
XCUTOFF, MAXPTS and QUADNO will be set according to
|
|
|
|
INITOPTIONS.
|
|
|
|
INITOPTIONS.
|
|
|
|
nc1c2 : scalar integer, optional
|
|
|
|
nc1c2 : scalar integer, optional
|
|
|
|
number of times to use the regression equation to restrict integration
|
|
|
|
number of times to use the regression equation to restrict
|
|
|
|
area. Nc1c2 = 1,2 is recommended. (default 2)
|
|
|
|
integration area. Nc1c2 = 1,2 is recommended. (default 2)
|
|
|
|
(note: works only for method >0)
|
|
|
|
(note: works only for method >0)
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
self.method = 3
|
|
|
|
self.method = 3
|
|
|
@ -336,7 +344,9 @@ class Rind(object):
|
|
|
|
Bup[0, ind] = minimum(Bup[0, ind], infinity * dev[indI[ind + 1]])
|
|
|
|
Bup[0, ind] = minimum(Bup[0, ind], infinity * dev[indI[ind + 1]])
|
|
|
|
Blo[0, ind] = maximum(Blo[0, ind], -infinity * dev[indI[ind + 1]])
|
|
|
|
Blo[0, ind] = maximum(Blo[0, ind], -infinity * dev[indI[ind + 1]])
|
|
|
|
ind2 = indI + 1
|
|
|
|
ind2 = indI + 1
|
|
|
|
return rindmod.rind(BIG, Ex, xc, nt, ind2, Blo, Bup, infin, seed) #@UndefinedVariable
|
|
|
|
|
|
|
|
|
|
|
|
return rindmod.rind(BIG, Ex, xc, nt, ind2, Blo, Bup, infin, seed) # @UndefinedVariable @IgnorePep8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_rind():
|
|
|
|
def test_rind():
|
|
|
|
''' Small test function
|
|
|
|
''' Small test function
|
|
|
@ -356,7 +366,7 @@ def test_rind():
|
|
|
|
|
|
|
|
|
|
|
|
A = repeat(Blo, n)
|
|
|
|
A = repeat(Blo, n)
|
|
|
|
B = repeat(Bup, n) # Integration limits
|
|
|
|
B = repeat(Bup, n) # Integration limits
|
|
|
|
E1 = rind(triu(Sc), m, A, B) #same as E0
|
|
|
|
_E1 = rind(triu(Sc), m, A, B) # same as E0
|
|
|
|
|
|
|
|
|
|
|
|
xc = zeros((0, 1))
|
|
|
|
xc = zeros((0, 1))
|
|
|
|
infinity = 37
|
|
|
|
infinity = 37
|
|
|
@ -365,7 +375,8 @@ def test_rind():
|
|
|
|
Bup, Blo = atleast_2d(Bup, Blo)
|
|
|
|
Bup, Blo = atleast_2d(Bup, Blo)
|
|
|
|
Bup[0, ind] = minimum(Bup[0, ind], infinity * dev[indI[ind + 1]])
|
|
|
|
Bup[0, ind] = minimum(Bup[0, ind], infinity * dev[indI[ind + 1]])
|
|
|
|
Blo[0, ind] = maximum(Blo[0, ind], -infinity * dev[indI[ind + 1]])
|
|
|
|
Blo[0, ind] = maximum(Blo[0, ind], -infinity * dev[indI[ind + 1]])
|
|
|
|
E3 = rind(Sc, m, Blo, Bup, indI, xc, nt=1)
|
|
|
|
_E3 = rind(Sc, m, Blo, Bup, indI, xc, nt=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cdflomax(x, alpha, m0):
|
|
|
|
def cdflomax(x, alpha, m0):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
@ -423,9 +434,10 @@ def cdflomax(x, alpha, m0):
|
|
|
|
c2 = alpha * c1
|
|
|
|
c2 = alpha * c1
|
|
|
|
return cdfnorm(c1) - alpha * exp(-x ** 2 / 2 / m0) * cdfnorm(c2)
|
|
|
|
return cdfnorm(c1) - alpha * exp(-x ** 2 / 2 / m0) * cdfnorm(c2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
|
|
|
|
def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return Multivariate normal or T probability with product correlation structure.
|
|
|
|
Return Multivariate normal or T probability with product correlation.
|
|
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
----------
|
|
|
@ -435,13 +447,14 @@ def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
|
|
|
|
where -1 < rho[i] < 1
|
|
|
|
where -1 < rho[i] < 1
|
|
|
|
a,b : array-like
|
|
|
|
a,b : array-like
|
|
|
|
vector of lower and upper integration limits, respectively.
|
|
|
|
vector of lower and upper integration limits, respectively.
|
|
|
|
Note: any values greater the 37 in magnitude, are considered as infinite values.
|
|
|
|
Note: any values greater the 37 in magnitude, are considered as
|
|
|
|
|
|
|
|
infinite values.
|
|
|
|
D : array-like
|
|
|
|
D : array-like
|
|
|
|
vector of means (default zeros(size(rho)))
|
|
|
|
vector of means (default zeros(size(rho)))
|
|
|
|
df = Degrees of freedom, NDF<=0 gives normal probabilities (default)
|
|
|
|
df = Degrees of freedom, NDF<=0 gives normal probabilities (default)
|
|
|
|
abseps = absolute error tolerance. (default 1e-4)
|
|
|
|
abseps = absolute error tolerance. (default 1e-4)
|
|
|
|
IERC = 1 if strict error control based on fourth derivative
|
|
|
|
IERC = 1 if strict error control based on fourth derivative
|
|
|
|
0 if intuitive error control based on halving the intervals (default)
|
|
|
|
0 if error control based on halving the intervals (default)
|
|
|
|
HNC = start interval width of simpson rule (default 0.24)
|
|
|
|
HNC = start interval width of simpson rule (default 0.24)
|
|
|
|
|
|
|
|
|
|
|
|
Returns
|
|
|
|
Returns
|
|
|
@ -453,7 +466,7 @@ def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
|
|
|
|
1, if N > 1000 or N < 1.
|
|
|
|
1, if N > 1000 or N < 1.
|
|
|
|
2, IF any abs(rho)>=1
|
|
|
|
2, IF any abs(rho)>=1
|
|
|
|
4, if ANY(b(I)<=A(i))
|
|
|
|
4, if ANY(b(I)<=A(i))
|
|
|
|
5, if number of terms computed exceeds maximum number of evaluation points
|
|
|
|
5, if number of terms exceeds maximum number of evaluation points
|
|
|
|
6, if fault accurs in normal subroutines
|
|
|
|
6, if fault accurs in normal subroutines
|
|
|
|
7, if subintervals are too narrow or too many
|
|
|
|
7, if subintervals are too narrow or too many
|
|
|
|
8, if bounds exceeds abseps
|
|
|
|
8, if bounds exceeds abseps
|
|
|
@ -465,12 +478,12 @@ def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
|
|
|
|
Example:
|
|
|
|
Example:
|
|
|
|
--------
|
|
|
|
--------
|
|
|
|
>>> import wafo.gaussian as wg
|
|
|
|
>>> import wafo.gaussian as wg
|
|
|
|
>>> rho2 = np.random.rand(2);
|
|
|
|
>>> rho2 = np.random.rand(2)
|
|
|
|
>>> a2 = np.zeros(2);
|
|
|
|
>>> a2 = np.zeros(2)
|
|
|
|
>>> b2 = np.repeat(np.inf,2);
|
|
|
|
>>> b2 = np.repeat(np.inf,2)
|
|
|
|
>>> [val2,err2, ift2] = wg.prbnormtndpc(rho2,a2,b2)
|
|
|
|
>>> [val2,err2, ift2] = wg.prbnormtndpc(rho2,a2,b2)
|
|
|
|
>>> g2 = lambda x : 0.25+np.arcsin(x[0]*x[1])/(2*pi)
|
|
|
|
>>> g2 = lambda x : 0.25+np.arcsin(x[0]*x[1])/(2*pi)
|
|
|
|
>>> E2 = g2(rho2) #% exact value
|
|
|
|
>>> E2 = g2(rho2) # exact value
|
|
|
|
>>> np.abs(E2-val2)<err2
|
|
|
|
>>> np.abs(E2-val2)<err2
|
|
|
|
True
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
|
@ -500,9 +513,12 @@ def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
|
|
|
|
# Make sure integration limits are finite
|
|
|
|
# Make sure integration limits are finite
|
|
|
|
A = np.clip(a - D, -100, 100)
|
|
|
|
A = np.clip(a - D, -100, 100)
|
|
|
|
B = np.clip(b - D, -100, 100)
|
|
|
|
B = np.clip(b - D, -100, 100)
|
|
|
|
return mvnprdmod.prbnormtndpc(rho, A, B, df, abseps, IERC, HNC) #@UndefinedVariable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prbnormndpc(rho, a, b, abserr=1e-4, relerr=1e-4, usesimpson=True, usebreakpoints=False):
|
|
|
|
return mvnprdmod.prbnormtndpc(rho, A, B, df, abseps, IERC, HNC) # @UndefinedVariable @IgnorePep8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prbnormndpc(rho, a, b, abserr=1e-4, relerr=1e-4, usesimpson=True,
|
|
|
|
|
|
|
|
usebreakpoints=False):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return Multivariate Normal probabilities with product correlation
|
|
|
|
Return Multivariate Normal probabilities with product correlation
|
|
|
|
|
|
|
|
|
|
|
@ -527,9 +543,9 @@ def prbnormndpc(rho, a, b, abserr=1e-4, relerr=1e-4, usesimpson=True, usebreakpo
|
|
|
|
Example:
|
|
|
|
Example:
|
|
|
|
-------
|
|
|
|
-------
|
|
|
|
>>> import wafo.gaussian as wg
|
|
|
|
>>> import wafo.gaussian as wg
|
|
|
|
>>> rho2 = np.random.rand(2);
|
|
|
|
>>> rho2 = np.random.rand(2)
|
|
|
|
>>> a2 = np.zeros(2);
|
|
|
|
>>> a2 = np.zeros(2)
|
|
|
|
>>> b2 = np.repeat(np.inf,2);
|
|
|
|
>>> b2 = np.repeat(np.inf,2)
|
|
|
|
>>> [val2,err2, ift2] = wg.prbnormndpc(rho2,a2,b2)
|
|
|
|
>>> [val2,err2, ift2] = wg.prbnormndpc(rho2,a2,b2)
|
|
|
|
>>> g2 = lambda x : 0.25+np.arcsin(x[0]*x[1])/(2*pi)
|
|
|
|
>>> g2 = lambda x : 0.25+np.arcsin(x[0]*x[1])/(2*pi)
|
|
|
|
>>> E2 = g2(rho2) #% exact value
|
|
|
|
>>> E2 = g2(rho2) #% exact value
|
|
|
@ -561,10 +577,11 @@ def prbnormndpc(rho, a, b, abserr=1e-4, relerr=1e-4, usesimpson=True, usebreakpo
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
# Call fortran implementation
|
|
|
|
# Call fortran implementation
|
|
|
|
val, err, ier = mvnprdmod.prbnormndpc(rho, a, b, abserr, relerr, usebreakpoints, usesimpson); #@UndefinedVariable
|
|
|
|
val, err, ier = mvnprdmod.prbnormndpc(rho, a, b, abserr, relerr, usebreakpoints, usesimpson) # @UndefinedVariable @IgnorePep8
|
|
|
|
|
|
|
|
|
|
|
|
if ier > 0:
|
|
|
|
if ier > 0:
|
|
|
|
warnings.warn('Abnormal termination ier = %d\n\n%s' % (ier, _ERRORMESSAGE[ier]))
|
|
|
|
warnings.warn('Abnormal termination ier = %d\n\n%s' %
|
|
|
|
|
|
|
|
(ier, _ERRORMESSAGE[ier]))
|
|
|
|
return val, err, ier
|
|
|
|
return val, err, ier
|
|
|
|
|
|
|
|
|
|
|
|
_ERRORMESSAGE = {}
|
|
|
|
_ERRORMESSAGE = {}
|
|
|
@ -577,22 +594,26 @@ _ERRORMESSAGE[1] = '''
|
|
|
|
determine the integration difficulties. if the position of a local
|
|
|
|
determine the integration difficulties. if the position of a local
|
|
|
|
difficulty can be determined (i.e. singularity discontinuity within
|
|
|
|
difficulty can be determined (i.e. singularity discontinuity within
|
|
|
|
the interval), it should be supplied to the routine as an element of
|
|
|
|
the interval), it should be supplied to the routine as an element of
|
|
|
|
the vector points. If necessary an appropriate special-purpose integrator
|
|
|
|
the vector points. If necessary an appropriate special-purpose
|
|
|
|
must be used, which is designed for handling the type of difficulty involved.
|
|
|
|
integrator must be used, which is designed for handling the type of
|
|
|
|
|
|
|
|
difficulty involved.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
_ERRORMESSAGE[2] = '''
|
|
|
|
_ERRORMESSAGE[2] = '''
|
|
|
|
the occurrence of roundoff error is detected, which prevents the requested
|
|
|
|
the occurrence of roundoff error is detected, which prevents the requested
|
|
|
|
tolerance from being achieved. The error may be under-estimated.'''
|
|
|
|
tolerance from being achieved. The error may be under-estimated.'''
|
|
|
|
|
|
|
|
|
|
|
|
_ERRORMESSAGE[3] = '''
|
|
|
|
_ERRORMESSAGE[3] = '''
|
|
|
|
Extremely bad integrand behaviour occurs at some points of the integration interval.'''
|
|
|
|
Extremely bad integrand behaviour occurs at some points of the integration
|
|
|
|
|
|
|
|
interval.'''
|
|
|
|
_ERRORMESSAGE[4] = '''
|
|
|
|
_ERRORMESSAGE[4] = '''
|
|
|
|
The algorithm does not converge. Roundoff error is detected in the extrapolation table.
|
|
|
|
The algorithm does not converge. Roundoff error is detected in the
|
|
|
|
It is presumed that the requested tolerance cannot be achieved, and that
|
|
|
|
extrapolation table. It is presumed that the requested tolerance cannot be
|
|
|
|
the returned result is the best which can be obtained.'''
|
|
|
|
achieved, and that the returned result is the best which can be obtained.
|
|
|
|
|
|
|
|
'''
|
|
|
|
_ERRORMESSAGE[5] = '''
|
|
|
|
_ERRORMESSAGE[5] = '''
|
|
|
|
The integral is probably divergent, or slowly convergent.
|
|
|
|
The integral is probably divergent, or slowly convergent.
|
|
|
|
It must be noted that divergence can occur with any other value of ier>0.'''
|
|
|
|
It must be noted that divergence can occur with any other value of ier>0.
|
|
|
|
|
|
|
|
'''
|
|
|
|
_ERRORMESSAGE[6] = '''the input is invalid because:
|
|
|
|
_ERRORMESSAGE[6] = '''the input is invalid because:
|
|
|
|
1) npts2 < 2
|
|
|
|
1) npts2 < 2
|
|
|
|
2) break points are specified outside the integration range
|
|
|
|
2) break points are specified outside the integration range
|
|
|
@ -612,13 +633,12 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
|
|
|
|
ABSEPS = absolute error tolerance.
|
|
|
|
ABSEPS = absolute error tolerance.
|
|
|
|
RELEPS = relative error tolerance.
|
|
|
|
RELEPS = relative error tolerance.
|
|
|
|
MAXPTS = maximum number of function values allowed. This
|
|
|
|
MAXPTS = maximum number of function values allowed. This
|
|
|
|
parameter can be used to limit the time. A sensible
|
|
|
|
parameter can be used to limit the time. A sensible strategy is to
|
|
|
|
strategy is to start with MAXPTS = 1000*N, and then
|
|
|
|
start with MAXPTS = 1000*N, and then increase MAXPTS if ERROR is too
|
|
|
|
increase MAXPTS if ERROR is too large.
|
|
|
|
large.
|
|
|
|
METHOD = integer defining the integration method
|
|
|
|
METHOD = integer defining the integration method
|
|
|
|
-1 KRBVRC randomized Korobov rules for the first 20
|
|
|
|
-1 KRBVRC randomized Korobov rules for the first 20 variables,
|
|
|
|
variables, randomized Richtmeyer rules for the rest,
|
|
|
|
randomized Richtmeyer rules for the rest, NMAX = 500
|
|
|
|
NMAX = 500
|
|
|
|
|
|
|
|
0 KRBVRC, NMAX = 100 (default)
|
|
|
|
0 KRBVRC, NMAX = 100 (default)
|
|
|
|
1 SADAPT Subregion Adaptive integration method, NMAX = 20
|
|
|
|
1 SADAPT Subregion Adaptive integration method, NMAX = 20
|
|
|
|
2 KROBOV Randomized KOROBOV rules, NMAX = 100
|
|
|
|
2 KROBOV Randomized KOROBOV rules, NMAX = 100
|
|
|
@ -667,7 +687,6 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
|
|
|
|
prbnormndpc, Rind
|
|
|
|
prbnormndpc, Rind
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m, n = correl.shape
|
|
|
|
m, n = correl.shape
|
|
|
|
Na = len(a)
|
|
|
|
Na = len(a)
|
|
|
|
Nb = len(b)
|
|
|
|
Nb = len(b)
|
|
|
@ -677,7 +696,7 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
|
|
|
|
if maxpts is None:
|
|
|
|
if maxpts is None:
|
|
|
|
maxpts = 1000 * n
|
|
|
|
maxpts = 1000 * n
|
|
|
|
|
|
|
|
|
|
|
|
maxpts = max(round(maxpts), 10 * n);
|
|
|
|
maxpts = max(round(maxpts), 10 * n)
|
|
|
|
|
|
|
|
|
|
|
|
# % array of correlation coefficients; the correlation
|
|
|
|
# % array of correlation coefficients; the correlation
|
|
|
|
# % coefficient in row I column J of the correlation matrix
|
|
|
|
# % coefficient in row I column J of the correlation matrix
|
|
|
@ -697,7 +716,7 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
|
|
|
|
infinity = 37
|
|
|
|
infinity = 37
|
|
|
|
infin = np.repeat(2, n) - (B > infinity) - 2 * (A < -infinity)
|
|
|
|
infin = np.repeat(2, n) - (B > infinity) - 2 * (A < -infinity)
|
|
|
|
|
|
|
|
|
|
|
|
err, val, inform = mvn.mvndst(A, B, infin, L, maxpts, abseps, releps) #@UndefinedVariable
|
|
|
|
err, val, inform = mvn.mvndst(A, B, infin, L, maxpts, abseps, releps) # @UndefinedVariable @IgnorePep8
|
|
|
|
|
|
|
|
|
|
|
|
return val, err, inform
|
|
|
|
return val, err, inform
|
|
|
|
|
|
|
|
|
|
|
@ -715,15 +734,18 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
|
|
|
|
# exTime = etime(clock,t0);
|
|
|
|
# exTime = etime(clock,t0);
|
|
|
|
# '
|
|
|
|
# '
|
|
|
|
|
|
|
|
|
|
|
|
#% gauss legendre points and weights, n = 6
|
|
|
|
# gauss legendre points and weights, n = 6
|
|
|
|
_W6 = [0.1713244923791705e+00, 0.3607615730481384e+00, 0.4679139345726904e+00]
|
|
|
|
_W6 = [0.1713244923791705e+00, 0.3607615730481384e+00, 0.4679139345726904e+00]
|
|
|
|
_X6 = [-0.9324695142031522e+00, -0.6612093864662647e+00, -0.2386191860831970e+00]
|
|
|
|
_X6 = [-0.9324695142031522e+00, -
|
|
|
|
#% gauss legendre points and weights, n = 12
|
|
|
|
0.6612093864662647e+00, -0.2386191860831970e+00]
|
|
|
|
|
|
|
|
# gauss legendre points and weights, n = 12
|
|
|
|
_W12 = [0.4717533638651177e-01, 0.1069393259953183e+00, 0.1600783285433464e+00,
|
|
|
|
_W12 = [0.4717533638651177e-01, 0.1069393259953183e+00, 0.1600783285433464e+00,
|
|
|
|
0.2031674267230659e+00, 0.2334925365383547e+00, 0.2491470458134029e+00]
|
|
|
|
0.2031674267230659e+00, 0.2334925365383547e+00, 0.2491470458134029e+00]
|
|
|
|
_X12 = [ -0.9815606342467191e+00, -0.9041172563704750e+00, -0.7699026741943050e+00,
|
|
|
|
_X12 = [-0.9815606342467191e+00, -0.9041172563704750e+00,
|
|
|
|
- 0.5873179542866171e+00, -0.3678314989981802e+00, -0.1252334085114692e+00]
|
|
|
|
-0.7699026741943050e+00,
|
|
|
|
#% gauss legendre points and weights, n = 20
|
|
|
|
- 0.5873179542866171e+00, -0.3678314989981802e+00,
|
|
|
|
|
|
|
|
-0.1252334085114692e+00]
|
|
|
|
|
|
|
|
# gauss legendre points and weights, n = 20
|
|
|
|
_W20 = [0.1761400713915212e-01, 0.4060142980038694e-01,
|
|
|
|
_W20 = [0.1761400713915212e-01, 0.4060142980038694e-01,
|
|
|
|
0.6267204833410906e-01, 0.8327674157670475e-01,
|
|
|
|
0.6267204833410906e-01, 0.8327674157670475e-01,
|
|
|
|
0.1019301198172404e+00, 0.1181945319615184e+00,
|
|
|
|
0.1019301198172404e+00, 0.1181945319615184e+00,
|
|
|
@ -735,6 +757,7 @@ _X20 = [ -0.9931285991850949e+00, -0.9639719272779138e+00,
|
|
|
|
- 0.5108670019508271e+00, -0.3737060887154196e+00,
|
|
|
|
- 0.5108670019508271e+00, -0.3737060887154196e+00,
|
|
|
|
- 0.2277858511416451e+00, -0.7652652113349733e-01]
|
|
|
|
- 0.2277858511416451e+00, -0.7652652113349733e-01]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cdfnorm2d(b1, b2, r):
|
|
|
|
def cdfnorm2d(b1, b2, r):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Returnc Bivariate Normal cumulative distribution function
|
|
|
|
Returnc Bivariate Normal cumulative distribution function
|
|
|
@ -798,8 +821,8 @@ def cdfnorm2d(b1, b2, r):
|
|
|
|
|
|
|
|
|
|
|
|
bvn = where(abs(r) > 1, nan, 0.0)
|
|
|
|
bvn = where(abs(r) > 1, nan, 0.0)
|
|
|
|
|
|
|
|
|
|
|
|
two = 2.e0;
|
|
|
|
two = 2.e0
|
|
|
|
twopi = 6.283185307179586e0;
|
|
|
|
twopi = 6.283185307179586e0
|
|
|
|
|
|
|
|
|
|
|
|
hk = h * k
|
|
|
|
hk = h * k
|
|
|
|
|
|
|
|
|
|
|
@ -813,90 +836,97 @@ def cdfnorm2d(b1, b2, r):
|
|
|
|
for i in range(10):
|
|
|
|
for i in range(10):
|
|
|
|
for sign in - 1, 1:
|
|
|
|
for sign in - 1, 1:
|
|
|
|
sn = sin(asr[k1] * (sign * _X20[i] + 1) / 2)
|
|
|
|
sn = sin(asr[k1] * (sign * _X20[i] + 1) / 2)
|
|
|
|
bvn[k01] = bvn[k01] + _W20[i] * exp((sn * hk[k01] - hs[k1]) / (1 - sn * sn));
|
|
|
|
bvn[k01] = bvn[k01] + _W20[i] * \
|
|
|
|
|
|
|
|
exp((sn * hk[k01] - hs[k1]) / (1 - sn * sn))
|
|
|
|
|
|
|
|
|
|
|
|
k1, = nonzero((0.3 <= r[k0]) & (r[k0] < 0.75))
|
|
|
|
k1, = nonzero((0.3 <= r[k0]) & (r[k0] < 0.75))
|
|
|
|
if len(k1) > 0:
|
|
|
|
if len(k1) > 0:
|
|
|
|
k01 = k0[k1];
|
|
|
|
k01 = k0[k1]
|
|
|
|
for i in range(6):
|
|
|
|
for i in range(6):
|
|
|
|
for sign in - 1, 1:
|
|
|
|
for sign in - 1, 1:
|
|
|
|
sn = sin(asr[k1] * (sign * _X12[i] + 1) / 2);
|
|
|
|
sn = sin(asr[k1] * (sign * _X12[i] + 1) / 2)
|
|
|
|
bvn[k01] = bvn[k01] + _W12[i] * exp((sn * hk[k01] - hs[k1]) / (1 - sn * sn));
|
|
|
|
bvn[k01] = bvn[k01] + _W12[i] * \
|
|
|
|
|
|
|
|
exp((sn * hk[k01] - hs[k1]) / (1 - sn * sn))
|
|
|
|
|
|
|
|
|
|
|
|
k1, = nonzero(r[k0] < 0.3);
|
|
|
|
k1, = nonzero(r[k0] < 0.3)
|
|
|
|
if len(k1) > 0:
|
|
|
|
if len(k1) > 0:
|
|
|
|
k01 = k0[k1]
|
|
|
|
k01 = k0[k1]
|
|
|
|
for i in range(3):
|
|
|
|
for i in range(3):
|
|
|
|
for sign in - 1, 1:
|
|
|
|
for sign in - 1, 1:
|
|
|
|
sn = sin(asr[k1] * (sign * _X6[i] + 1) / 2)
|
|
|
|
sn = sin(asr[k1] * (sign * _X6[i] + 1) / 2)
|
|
|
|
bvn[k01] = bvn[k01] + _W6[i] * exp((sn * hk[k01] - hs[k1]) / (1 - sn * sn))
|
|
|
|
bvn[k01] = bvn[k01] + _W6[i] * \
|
|
|
|
|
|
|
|
exp((sn * hk[k01] - hs[k1]) / (1 - sn * sn))
|
|
|
|
|
|
|
|
|
|
|
|
bvn[k0] *= asr / (two * twopi)
|
|
|
|
bvn[k0] *= asr / (two * twopi)
|
|
|
|
bvn[k0] += fi(-h[k0]) * fi(-k[k0])
|
|
|
|
bvn[k0] += fi(-h[k0]) * fi(-k[k0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
k1, = nonzero((0.925 <= abs(r)) & (abs(r) <= 1))
|
|
|
|
k1, = nonzero((0.925 <= abs(r)) & (abs(r) <= 1));
|
|
|
|
|
|
|
|
if len(k1) > 0:
|
|
|
|
if len(k1) > 0:
|
|
|
|
k2, = nonzero(r[k1] < 0);
|
|
|
|
k2, = nonzero(r[k1] < 0)
|
|
|
|
if len(k2) > 0:
|
|
|
|
if len(k2) > 0:
|
|
|
|
k12 = k1[k2];
|
|
|
|
k12 = k1[k2]
|
|
|
|
k[k12] = -k[k12];
|
|
|
|
k[k12] = -k[k12]
|
|
|
|
hk[k12] = -hk[k12];
|
|
|
|
hk[k12] = -hk[k12]
|
|
|
|
|
|
|
|
|
|
|
|
k3, = nonzero(abs(r[k1]) < 1);
|
|
|
|
k3, = nonzero(abs(r[k1]) < 1)
|
|
|
|
if len(k3) > 0:
|
|
|
|
if len(k3) > 0:
|
|
|
|
k13 = k1[k3];
|
|
|
|
k13 = k1[k3]
|
|
|
|
a2 = (1 - r[k13]) * (1 + r[k13]);
|
|
|
|
a2 = (1 - r[k13]) * (1 + r[k13])
|
|
|
|
a = sqrt(a2)
|
|
|
|
a = sqrt(a2)
|
|
|
|
b = abs(h[k13] - k[k13]);
|
|
|
|
b = abs(h[k13] - k[k13])
|
|
|
|
bs = b * b;
|
|
|
|
bs = b * b
|
|
|
|
c = (4.e0 - hk[k13]) / 8.e0;
|
|
|
|
c = (4.e0 - hk[k13]) / 8.e0
|
|
|
|
d = (12.e0 - hk[k13]) / 16.e0;
|
|
|
|
d = (12.e0 - hk[k13]) / 16.e0
|
|
|
|
asr = -(bs / a2 + hk[k13]) / 2.e0;
|
|
|
|
asr = -(bs / a2 + hk[k13]) / 2.e0
|
|
|
|
k4, = nonzero(asr > -100.e0);
|
|
|
|
k4, = nonzero(asr > -100.e0)
|
|
|
|
if len(k4) > 0:
|
|
|
|
if len(k4) > 0:
|
|
|
|
bvn[k13[k4]] = a[k4] * exp(asr[k4]) * (1 - c[k4] *
|
|
|
|
bvn[k13[k4]] = (a[k4] * exp(asr[k4]) *
|
|
|
|
(bs[k4] - a2[k4]) * (1 - d[k4] * bs[k4] / 5) / 3
|
|
|
|
(1 - c[k4] * (bs[k4] - a2[k4]) *
|
|
|
|
+ c[k4] * d[k4] * a2[k4] ** 2 / 5);
|
|
|
|
(1 - d[k4] * bs[k4] / 5) / 3 +
|
|
|
|
|
|
|
|
c[k4] * d[k4] * a2[k4] ** 2 / 5))
|
|
|
|
|
|
|
|
|
|
|
|
k5, = nonzero(hk[k13] < 100.e0);
|
|
|
|
k5, = nonzero(hk[k13] < 100.e0)
|
|
|
|
if len(k5) > 0:
|
|
|
|
if len(k5) > 0:
|
|
|
|
#% b = sqrt(bs);
|
|
|
|
# b = sqrt(bs);
|
|
|
|
k135 = k13[k5];
|
|
|
|
k135 = k13[k5]
|
|
|
|
bvn[k135] = bvn[k135] - exp(-hk[k135] / 2) * sqrt(twopi) * fi(-b[k5] / a[k5]) * b[k5] * (1 - c[k5] * bs[k5] * (1 - d[k5] * bs[k5] / 5) / 3)
|
|
|
|
bvn[k135] = bvn[k135] - exp(-hk[k135] / 2) * sqrt(twopi) * fi(-b[k5] / a[k5]) * \
|
|
|
|
|
|
|
|
b[k5] * (1 - c[k5] * bs[k5] * (1 - d[k5] * bs[k5] / 5) / 3)
|
|
|
|
|
|
|
|
|
|
|
|
a /= two
|
|
|
|
a /= two
|
|
|
|
for i in range(10):
|
|
|
|
for i in range(10):
|
|
|
|
for sign in - 1, 1:
|
|
|
|
for sign in - 1, 1:
|
|
|
|
xs = (a * (sign * _X20[i] + 1)) ** 2;
|
|
|
|
xs = (a * (sign * _X20[i] + 1)) ** 2
|
|
|
|
rs = sqrt(1 - xs);
|
|
|
|
rs = sqrt(1 - xs)
|
|
|
|
asr = -(bs / xs + hk[k13]) / 2;
|
|
|
|
asr = -(bs / xs + hk[k13]) / 2
|
|
|
|
k6, = nonzero(asr > -100.e0) ;
|
|
|
|
k6, = nonzero(asr > -100.e0)
|
|
|
|
if len(k6) > 0:
|
|
|
|
if len(k6) > 0:
|
|
|
|
k136 = k13[k6]
|
|
|
|
k136 = k13[k6]
|
|
|
|
bvn[k136] += (a[k6] * _W20[i] * exp(asr[k6]) *
|
|
|
|
bvn[k136] += (a[k6] * _W20[i] * exp(asr[k6]) *
|
|
|
|
(exp(-hk[k136] * (1 - rs[k6]) / (2 * (1 + rs[k6]))) / rs[k6] -
|
|
|
|
(exp(-hk[k136] * (1 - rs[k6]) /
|
|
|
|
(1 + c[k6] * xs[k6] * (1 + d[k6] * xs[k6]))))
|
|
|
|
(2 * (1 + rs[k6]))) / rs[k6] -
|
|
|
|
|
|
|
|
(1 + c[k6] * xs[k6] *
|
|
|
|
|
|
|
|
(1 + d[k6] * xs[k6]))))
|
|
|
|
|
|
|
|
|
|
|
|
bvn[k3] = -bvn[k3] / twopi;
|
|
|
|
bvn[k3] = -bvn[k3] / twopi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
k7, = nonzero(r[k1] > 0)
|
|
|
|
k7, = nonzero(r[k1] > 0);
|
|
|
|
|
|
|
|
if len(k7):
|
|
|
|
if len(k7):
|
|
|
|
k17 = k1[k7]
|
|
|
|
k17 = k1[k7]
|
|
|
|
bvn[k17] += fi(-np.maximum(h[k17], k[k17]));
|
|
|
|
bvn[k17] += fi(-np.maximum(h[k17], k[k17]))
|
|
|
|
|
|
|
|
|
|
|
|
k8, = nonzero(r[k1] < 0);
|
|
|
|
k8, = nonzero(r[k1] < 0)
|
|
|
|
if len(k8) > 0:
|
|
|
|
if len(k8) > 0:
|
|
|
|
k18 = k1[k8];
|
|
|
|
k18 = k1[k8]
|
|
|
|
bvn[k18] = -bvn[k18] + np.maximum(0, fi(-h[k18]) - fi(-k[k18]));
|
|
|
|
bvn[k18] = -bvn[k18] + np.maximum(0, fi(-h[k18]) - fi(-k[k18]))
|
|
|
|
|
|
|
|
|
|
|
|
bvn.shape = cshape
|
|
|
|
bvn.shape = cshape
|
|
|
|
return bvn
|
|
|
|
return bvn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fi(x):
|
|
|
|
def fi(x):
|
|
|
|
return 0.5 * (erfc((-x) / sqrt(2)))
|
|
|
|
return 0.5 * (erfc((-x) / sqrt(2)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prbnorm2d(a, b, r):
|
|
|
|
def prbnorm2d(a, b, r):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Returns Bivariate Normal probability
|
|
|
|
Returns Bivariate Normal probability
|
|
|
@ -945,13 +975,17 @@ def prbnorm2d(a, b, r):
|
|
|
|
- bvd(lower[0], upper[1], correl)
|
|
|
|
- bvd(lower[0], upper[1], correl)
|
|
|
|
+ bvd(upper[0], upper[1], correl))
|
|
|
|
+ bvd(upper[0], upper[1], correl))
|
|
|
|
elif (infin[0] == 2 and infin[1] == 1):
|
|
|
|
elif (infin[0] == 2 and infin[1] == 1):
|
|
|
|
return bvd(lower[0], lower[1], correl) - bvd(upper[0], lower[1], correl)
|
|
|
|
return (bvd(lower[0], lower[1], correl) -
|
|
|
|
|
|
|
|
bvd(upper[0], lower[1], correl))
|
|
|
|
elif (infin[0] == 1 and infin[1] == 2):
|
|
|
|
elif (infin[0] == 1 and infin[1] == 2):
|
|
|
|
return bvd(lower[0], lower[1], correl) - bvd(lower[0], upper[1], correl)
|
|
|
|
return (bvd(lower[0], lower[1], correl) -
|
|
|
|
|
|
|
|
bvd(lower[0], upper[1], correl))
|
|
|
|
elif (infin[0] == 2 and infin[1] == 0):
|
|
|
|
elif (infin[0] == 2 and infin[1] == 0):
|
|
|
|
return bvd(-upper[0], -upper[1], correl) - bvd(-lower[0], -upper[1], correl)
|
|
|
|
return (bvd(-upper[0], -upper[1], correl) -
|
|
|
|
|
|
|
|
bvd(-lower[0], -upper[1], correl))
|
|
|
|
elif (infin[0] == 0 and infin[1] == 2):
|
|
|
|
elif (infin[0] == 0 and infin[1] == 2):
|
|
|
|
return bvd(-upper[0], -upper[1], correl) - bvd(-upper[0], -lower[1], correl)
|
|
|
|
return (bvd(-upper[0], -upper[1], correl) -
|
|
|
|
|
|
|
|
bvd(-upper[0], -lower[1], correl))
|
|
|
|
elif (infin[0] == 1 and infin[1] == 0):
|
|
|
|
elif (infin[0] == 1 and infin[1] == 0):
|
|
|
|
return bvd(lower[0], -upper[1], -correl)
|
|
|
|
return bvd(lower[0], -upper[1], -correl)
|
|
|
|
elif (infin[0] == 0 and infin[1] == 1):
|
|
|
|
elif (infin[0] == 0 and infin[1] == 1):
|
|
|
@ -962,9 +996,11 @@ def prbnorm2d(a, b, r):
|
|
|
|
return bvd(-upper[0], -upper[1], correl)
|
|
|
|
return bvd(-upper[0], -upper[1], correl)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bvd(lo, up, r):
|
|
|
|
def bvd(lo, up, r):
|
|
|
|
return cdfnorm2d(-lo, -up, r)
|
|
|
|
return cdfnorm2d(-lo, -up, r)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_docstrings():
|
|
|
|
def test_docstrings():
|
|
|
|
import doctest
|
|
|
|
import doctest
|
|
|
|
doctest.testmod()
|
|
|
|
doctest.testmod()
|
|
|
|