def ppf(self, x): """ Computes the percent point function of the distribution at the point(s) x. It is defined as the inverse of the CDF. y = ppf(x) can be interpreted as the argument y for which the value of the cdf(x) is equal to y. Essentially that means the random varable y is the place on the distribution the CDF evaluates to x. Parameters ---------- x: array, dtype=float, shape=(m x n), bounds=(0,1) The value(s) at which the user would like the ppf evaluated. If an array is passed in, the ppf is evaluated at every point in the array and an array of the same size is returned. Returns ------- ppf: array, dtype=float, shape=(m x n) The ppf at each point in x. """ vals = np.ceil(bdtrik(x, self.n, self.p)) vals1 = vals - 1 temp = bdtr(vals1, self.n, self.p) ppf = np.where((temp >= x), vals1, vals) return ppf
def quantile(self, *q): """Quantile Function Also known as the inverse cumulative Distribution function, this function takes known quantiles and returns the associated `X` value from the support domain. .. math:: \begin{cases} 0 &\text{if } 0 \leq q \lt p 1 &\text{if } p \leq q \lt 1 \end{cases} Parameters ---------- q : numpy.ndarray, float The probabilities within domain [0, 1] Returns ------- numpy.ndarray The `X` values from the support domain associated with the input quantiles. """ # check array for numpy structure q = check_array(q, reduce_args=True, ensure_1d=True) out = np.ceil(sc.bdtrik(q, 1, self.bias)) return np.where(self.bias >= q, 0, out)
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.bdtrik(q, self.n_trials, 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.bdtr(X_down, self.n_trials, 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.bdtrik(q, n, p)) vals1 = np.maximum(vals - 1, 0) temp = special.bdtr(vals1, n, p) return np.where(temp >= q, vals1, vals)
def bdtrik_comp(y, n, p): return bdtrik(1-y, n, p)
def _ppf(self, q_data, size, prob): return numpy.ceil(special.bdtrik(q_data, numpy.floor(size), prob))