def _ve_gauss_(s, accept=lambda a: True, nmax=1000): """ Get the gaussian random number >>> v = ... ## the number with error ## get 100 random numbers >>> for i in range ( 0, 100 ) : print v.gauss() ## get only non-negative numbers >>> for j in range ( 0, 100 ) : print v.gauss( lambda s : s > 0 ) """ # if 0 >= s.cov2() or iszero(s.cov2()): return s.value() ## return # v = s.value() e = s.error() # for i in xrange(nmax): r = _gauss(v, e) if accept(r): return r logger.warning("Can'n generate proper random number %s" % s) return v
def zMass(mZ=91.188, wZ=2.495): """Return a gaussian distribution. Default has a mean of 91.188 and a width of 2.495.""" return _gauss(mZ, wZ * (2 * _sqrt(2 * _log(2))))