def quantile(self, *q): # check array for numpy structure q = check_array(q, reduce_args=True, ensure_1d=True) # get the upper value of X (ceiling) X_up = np.ceil(sc.nbdtrik(q, self.n_success, self.bias)) # get the lower value of X (floor) X_down = np.maximum(X_up - 1, 0) # recompute quantiles to validate transformation q_test = sc.nbdtr(X_down, self.n_success, self.bias) # when q_test is greater than true, shift output down out = np.where(q_test >= q, X_down, X_up).astype(int) # return only in-bound values return np.where(self.support.contains(out), out, np.nan)
def _ppf(self, q, n, p): vals = ceil(special.nbdtrik(q, n, p)) vals1 = (vals - 1).clip(0.0, np.inf) temp = self._cdf(vals1, n, p) return np.where(temp >= q, vals1, vals)
def nbdtrik_comp(y, n, p): return nbdtrik(1-y, n, p)
def _ppf(self, q, n, p): vals = ceil(special.nbdtrik(q, n, p)) vals1 = (vals-1).clip(0.0, np.inf) temp = self._cdf(vals1, n, p) return np.where(temp >= q, vals1, vals)