docs: def quantile_curve(quantile, curves, weights=None):
      """
      Compute the weighted quantile aggregate of a set of curves.
  
      :param quantile:
          Quantile value to calculate. Should be in the range [0.0, 1.0].
      :param curves:
          Array of R PoEs (possibly arrays)
      :param weights:
          Array-like of weights, 1 for each input curve, or None
      :returns:
          A numpy array representing the quantile aggregate
      """
      if not isinstance(curves, numpy.ndarray):
          curves = numpy.array(curves)
      R = len(curves)
      if weights is None:
          weights = numpy.ones(R) / R
      else:
          weights = numpy.array(weights)
          assert len(weights) == R, (len(weights), R)
      result = numpy.zeros(curves.shape[1:])
      for idx, _ in numpy.ndenumerate(result):
          data = numpy.array([a[idx] for a in curves])
          sorted_idxs = numpy.argsort(data)
          sorted_weights = weights[sorted_idxs]
          sorted_data = data[sorted_idxs]
          cum_weights = numpy.cumsum(sorted_weights)
          # get the quantile from the interpolated CDF
          result[idx] = numpy.interp(quantile, cum_weights, sorted_data)
      return result