code: def weighted_percentile(a, q, weights=None):
      """
      Compute the weighted q-th percentile of data
  
      Parameters
      ----------
      a : array_like
          Input that can be converted into an array.
      q : array_like[float]
          Percentile or sequence of percentiles to compute. Must be int
          the range [0, 100]
      weights : array_like
          Weights associated with the input values.
      """
      # Calculate and interpolate weighted percentiles
      # method derived from https://en.wikipedia.org/wiki/Percentile
      # using numpy's standard C = 1
      if weights is None:
          weights = np.ones(len(a))
  
      weights = np.asarray(weights)
      q = np.asarray(q)
  
      C = 1
      idx_s = np.argsort(a)
      a_s = a[idx_s]
      w_n = weights[idx_s]
      S_N = np.sum(weights)
      S_n = np.cumsum(w_n)
      p_n = (S_n - C * w_n) / (S_N + (1 - 2 * C) * w_n)
      pcts = np.interp(q / 100.0, p_n, a_s)
      return pcts
  
file_path: plotnine/plotnine/stats/stat_boxplot.py
imports: import numpy
  import pandas
  from .._utils import resolution
  from ..doctools import document
  from .stat import stat
label_desc: Use image node_id 1 for calling a global function with example usage: weighted_percentile(a, q, weights) and returns: pcts