build_cdf_lookup

halotools.utils.build_cdf_lookup(y, npts_lookup_table=1000)[source]

Compute a lookup table for the cumulative distribution function specified by the input set of y values.

The input data y will be used to define the CDF P(< y) in the usual way: the array y will be sorted, and the largest value corresponds to CDF value 1/npts_data, the second largest value 2/npts_data, etc. For performance reasons, this correspondence will be used to build a sparse lookup table of length npts_lookup_table. The accuracy of the returned CDF is fundamentally limited by npts_data, and optionally limited by npts_lookup_table.

Parameters:
yndarray

Numpy array of shape (npts_data, ) defining the distribution function of the returned lookup table.

npts_lookup_tableint, optional

Number of control points in the returned lookup table. Cannot exceed npts_data.

Returns:
x_tablendarray

Numpy array of shape (npts_lookup_table, ) storing the control points at which the CDF has been evaluated.

y_tablendarray

Numpy array of shape (npts_lookup_table, ) storing the values of the random variable associated with each control point in the x_table.

Examples

>>> y = np.random.normal(size=int(1e5))
>>> x_table, y_table = build_cdf_lookup(y, npts_lookup_table=100)