<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resample_equal(samples, weights, rstate=None):
 """ Resample a new set of points from the weighted set of inputs such that they all have equal weight. Each input sample appears in the output array either `floor(weights[i] * nsamples)` or `ceil(weights[i] * nsamples)` times, with `floor` or `ceil` randomly selected (weighted by proximity). Parameters samples : `~numpy.ndarray` with shape (nsamples,) Set of unequally weighted samples. weights : `~numpy.ndarray` with shape (nsamples,) Corresponding weight of each sample. rstate : `~numpy.random.RandomState`, optional `~numpy.random.RandomState` instance. Returns ------- equal_weight_samples : `~numpy.ndarray` with shape (nsamples,) New set of samples with equal weights. Examples -------- array([[ 1., 1.], [ 1., 1.], [ 1., 1.], [ 3., 3.]]) Notes ----- Implements the systematic resampling method described in `Hol, Schon, and Gustafsson (2006) <doi:10.1109/NSSPW.2006.4378824>`_. """


    if rstate is None:
        rstate = np.random

    if abs(np.sum(weights) - 1.) > SQRTEPS:  # same tol as in np.random.choice.
        raise ValueError("Weights do not sum to 1.")

    # Make N subdivisions and choose positions with a consistent random offset.
    nsamples = len(weights)
    positions = (rstate.random() + np.arange(nsamples)) / nsamples

    # Resample the data.
    idx = np.zeros(nsamples, dtype=np.int)
    cumulative_sum = np.cumsum(weights)
    i, j = 0, 0
    while i < nsamples:
        if positions[i] < cumulative_sum[j]:
            idx[i] = j
            i += 1
        else:
            j += 1

    return samples[idx]