make_cdf

zdm.optical_numerics.make_cdf(xs, ys, ws, norm=True)[source]

Build a weighted empirical CDF evaluated on a fixed grid.

For each grid point x in xs, accumulates the weights ws[i] of all observations ys[i] that fall below x. The result is a non-decreasing array that can be compared to a model prior CDF.

Parameters:
  • xs (np.ndarray) – Grid of x values at which to evaluate the CDF (e.g. apparent magnitude bin centres). Must be sorted in ascending order.

  • ys (array-like) – Observed data values (e.g. host galaxy apparent magnitudes).

  • ws (array-like) – Weight for each observation in ys (e.g. PATH posteriors P_Ox). Must have the same length as ys.

  • norm (bool, optional) – If True (default), normalise the CDF so that its maximum value is 1. Set to False to preserve the raw cumulative weight sum.

Returns:

cdf – Weighted empirical CDF evaluated at each point in xs.

Return type:

np.ndarray, shape (len(xs),)