def rstable_sym(self, alpha, location, scale, \ xmin=float('-inf'), xmax=float('inf'), \ pmin=0.0, pmax=1.0): """ The SYMMETRICAL stable distribution where alpha is the tail exponent. For numerical reasons alpha is restricted to [0.25, 0.9] and [1.125, 1.9] - but alpha = 1.0 (the Cauchy) and alpha = 2.0 (scaled normal) are also allowed! Numerics are somewhat crude but the fractional error is mostly < 0.001 - sometimes much less - and the absolute error is almost always < 0.001 - sometimes much less... NB This generator is slow - particularly for small alpha !!!!! """ self._checkminmax(xmin, xmax, pmin, pmax, 'rstable_sym') pmn = pmin pmx = pmax if xmin > float('-inf'):\ pmn = max(pmin, cstable_sym(alpha, location, scale, xmin)) if xmax < float('inf'): \ pmx = min(pmax, cstable_sym(alpha, location, scale, xmax)) p = pmn + (pmx-pmn)*self.runif01() x = istable_sym(p, alpha, location, scale) return x
def _fifi2fid(x): cdf = cstable_sym(alpha, location, scale, x) pdf = dstable_sym(alpha, location, scale, x) fi = cdf - prob if pdf <= 0.0: if fi == 0.0: fi2fid = 1.0 else: fi2fid = MAXFLOAT else: fi2fid = fi/pdf return fi, fi2fid