cogwheel.utils.resample_equal

cogwheel.utils.resample_equal(samples, weights_col='weights', num=None)

Resample a weighted DataFrame to produce equal-weight samples.

Draw num samples from a DataFrame of weighted samples, so that the resulting samples have equal weights. Note: this does not generally produce independent samples, and samples may be repeated.

Parameters:
samplespandas.DataFrame

Rows correspond to samples from a distribution.

weights_colstr

Name of a column in samples to interpret as weights.

numint, optional

Length of the returned DataFrame. Defaults to len(samples).

Returns:
pandas.DataFrame

A DataFrame containing num rows with equal-weight samples. The columns match those of samples, except that weights_col is removed.