cenreg.distribution package
Submodules
cenreg.distribution.cdf module
- class cenreg.distribution.cdf.CumulativeDist(b: ndarray, p: ndarray | None = None, cum_p: ndarray | None = None, interpolate: Literal['linear', 'left', 'right'] = 'linear', confidence_interval: ndarray | None = None)
Bases:
objectCumulative distribution function.
- cdf(y: float | ndarray) ndarray
Cumulative distribution function (i.e., inverse of quantile function).
- Parameters:
y (np.ndarray | float) – Values for which the CDF is computed. y can be a scalar or a one-dimensional array or a two-dimensional array.
- Returns:
cum_p – CDF values for each value in y.
- Return type:
np.ndarray
- icdf(quantiles: float | ndarray) ndarray
Inverse cumulative distribution function (i.e., quantile function).
If the input is 0.0, return self.b[0]. If the input is 1.0, return self.b[-1]. If the input is between 0.0 and 1.0, return the corresponding bin value.
Note: For any alpha in [0.0, 1.0], we usually assume that self.cdf(self.icdf(alpha)) == alpha holds. However, the inverse CDF of empirical distribution defined here does not always satisfy this property.
- Parameters:
quantiles (float | np.ndarray) – Quantiles for which the inverse CDF is computed.
- Returns:
icdf_values – Compute inverse CDF values for each value in quantiles.
- Return type:
np.ndarray
- survival_function(y: float | ndarray) ndarray
Survival function (i.e., 1 - CDF).
- Parameters:
y (np.ndarray | float) – Values for which the survival function is computed.
- Returns:
survival_values – Survival function values for each value in y. Array shape is equal to the shape of y.
- Return type:
np.ndarray
cenreg.distribution.interpolate module
- cenreg.distribution.interpolate.linear_interpolation(kx: ndarray, ky: ndarray, x: ndarray) ndarray
Linear interpolation.
- Parameters:
kx (np.ndarray) – One-dimensional or two-dimensional array containing the x-coordinates of the data points.
ky (np.ndarray) – One-dimensional or two-dimensional array containing the y-coordinates of the data points.
x (np.ndarray) – One-dimensional or two-dimensional array containing the x-coordinates where to evaluate the interpolated values.
- Returns:
ret – One-dimensional or two-dimensional array containing the interpolated values.
- Return type:
np.ndarray
cenreg.distribution.quantile module
- class cenreg.distribution.quantile.QuantileDist(q: ndarray, v: ndarray, interpolate: str = 'linear')
Bases:
objectQuantile function.
- cdf(y: float | int | ndarray)
Cumulative distribution function (i.e., inverse of quantile function).
- Parameters:
y (np.ndarray | float) – Values for which the CDF is computed.
- Returns:
cum_p – CDF values for each value in y. Array shape is equal to the shape of y.
- Return type:
np.ndarray
- icdf(quantiles: float | int | ndarray) ndarray
Inverse cumulative distribution function (i.e., quantile function).
If the input is 0.0, return self.v[0]. If the input is 1.0, return self.v[-1]. If the input is between 0.0 and 1.0, return the corresponding bin value.
- Parameters:
quantiles (float | np.ndarray) – Quantiles for which the inverse CDF is computed.
- Returns:
icdf_values – Compute inverse CDF values for each value in quantiles. Array shape is equal to the shape of quantiles.
- Return type:
np.ndarray
- survival_function(y: float | ndarray) ndarray
Survival function (i.e., 1 - CDF).
- Parameters:
y (np.ndarray | float) – Values for which the survival function is computed.
- Returns:
survival_values – Survival function values for each value in y. Array shape is equal to the shape of y.
- Return type:
np.ndarray