def cdf(self, q, lower_tail=True, log_p=False): """ The cdf of the distribution. Parameters ---------- q : array_like Variates at which to calculate the cdf. If any of `shape`, `a`, `b` or `xmin` are arrays, `q` must have the same length. lower_tail : logical, optional If `True` (default), probabilities are P[X <= q], otherwise, P[X > q]. log_p : logical, optional If `True`, probabilities *p* are interpreted as log(*p*). Returns ------- p : array_like The integrated probability of a variate being smaller than *q*. """ qt = self._xt(q) p = sp.gammainc(self._z, qt**self.b)/sp.gammainc(self._z, self._xmintb) return self._cdf_convert(p, lower_tail, log_p)
def raw_moments(self, n): """ Calculate the nth raw moment, E[X^n]. Parameters ---------- n : array_like The order(s) of the moment desired. Returns ------- mu_n : array_like The raw moment(s) corresponding to the order(s) `n`. Notes ----- The 1st raw moment is equivalent to the mean. Examples -------- >>> from mrpy.stats import TGGD >>> t = TGGD() >>> mean = t.raw_moments(1) >>> ten_moments = t.raw_moments(np.arange(10)) #doctest: +SKIP """ zn = (self.a + 1 + n)/self.b z0 = (self.a + 1)/self.b x = (self.xmin/self.scale)**self.b return self.scale**n*sp.gammainc(zn, x)/sp.gammainc(z0, x)
def rho_gtm(m, logHs, alpha, beta, mmin=None, mmax=np.inf, norm="pdf", log=False, **Arhoc_kw): """ The mass-weighted integral of the MRP, in reverse (ie. from high to low mass) %s """ t, A = _head(m, logHs, alpha, beta, mmin, norm, log, **Arhoc_kw) shape = 10**(2*logHs)*sp.gammainc((alpha + 2)/beta, (m/10**logHs)**beta) if log: shape = np.log(shape) return _tail(shape, A, log)
def central_moments(self, n): """ Calculate the nth central moment, E[(X-mu)^n]. Parameters ---------- n : integer The order of the moment desired. Returns ------- mu_n : float The nth central moment. Notes ----- The 2nd central moment is equivalent to the variance. Examples -------- >>> from mrpy.stats import TGGD >>> t = TGGD() >>> variance = t.central_moments(2) >>> t.raw_moments(10) 199064.8037313875 """ k = np.arange(n + 1) sign = (-1)**(n - k) zk = (self.a + 1 + k)/self.b z0 = (self.a + 1)/self.b z1 = (self.a + 2)/self.b x = (self.xmin/self.scale)**self.b coeffs = _comb(n, k) return self.scale**n*np.sum(coeffs*sp.gammainc(z1, x)**(n - k)* sp.gammainc(zk, x)*sign/sp.gammainc(z0, x)**(n - k + 1))
def _pdf_norm(self, log=False): a = sp.gammainc(self._z, self._xmintb) if not log: return a else: return np.log(a)
def _gammainc_zx_(self): """ The incomplete gamma function, Gamma(z,x), where z,x are as specified in this class. """ return sp.gammainc(self._z, self._x_)
def gammainc_z1xd(self): return sp.gammainc(self._zd + self.beta / self.betad, self._xd)
def gammainc_z1x(self): return sp.gammainc(self._z + 1, self._x)
def gammainc_zxd(self): return sp.gammainc(self._zd, self._xd)
def _qd_nos(self): """ q for the data parameters, without scaling. """ return sp.gammainc((self.alphad+1)/self.betad, self._xd)*self.Hsd
def _qd(self): """ The normalisation of the MRP (ie. integral of g) (truncation masses) """ return sp.gammainc(self._zd, self._xd)*self.Hsd