calpit.utils
Functions
|
Normalizes conditional density estimates to be non-negative and integrate to one. |
|
|
|
Does trapezoid integration between the same limits as the grid. |
|
Same as trapz_grid but implemented in Pytorch |
|
Plots the PIT/HPD histogram and calculates the confidence interval for the bin values, |
Module Contents
- normalize(cde_estimates: numpy.ndarray, y_grid: numpy.ndarray, tol: float = 1e-06, max_iter: int = 200) numpy.ndarray[source]
Normalizes conditional density estimates to be non-negative and integrate to one.
- Parameters:
cde_estimates (numpy.ndarray) – A numpy array or matrix of conditional density estimates.
x_grid (numpy.ndarray) – The array of grid points.
tol (float) – The tolerance to accept for abs(area - 1).
max_iter (int) – The maximal number of search iterations.
- Returns:
The normalized conditional density estimates.
- Return type:
numpy.ndarray
- trapz_grid(y: numpy.ndarray, x: numpy.ndarray) numpy.ndarray[source]
Does trapezoid integration between the same limits as the grid.
- Parameters:
y (np.ndarray) – The array of values to integrate.
x (np.ndarray) – The array of grid points.
- Returns:
The integrated values.
- Return type:
np.ndarray
- trapz_grid_torch(y: torch.tensor, x: torch.tensor) torch.tensor[source]
Same as trapz_grid but implemented in Pytorch
- plot_pit(pit_values, ci_level, n_bins=30, y_true=None, ax=None, **fig_kw)[source]
Plots the PIT/HPD histogram and calculates the confidence interval for the bin values, were the PIT/HPD values follow an uniform distribution
@param values: a numpy array with PIT/HPD values @param ci_level: a float between 0 and 1 indicating the size of the confidence level @param x_label: a string, populates the x_label of the plot @param n_bins: an integer, the number of bins in the histogram @param figsize: a tuple, the plot size (width, height) @param ylim: a list of two elements, including the lower and upper limit for the y axis @returns The matplotlib figure object with the histogram of the PIT/HPD values and the CI for the uniform distribution