class_docstr: Compute Sina plot values
  
  {usage}
  
  Parameters
  ----------
  {common_parameters}
  binwidth : float, default=None
      The width of the bins. The default is to use bins that
      cover the range of the data. You should always override this
      value, exploring multiple widths to find the best to
      illustrate the stories in your data.
  bins : int, default=50
      Number of bins. Overridden by binwidth.
  method : Literal["density", "counts"], default="density"
      Choose the method to spread the samples within the same bin
      along the x-axis. Available methods: "density", "counts"
      (can be abbreviated, e.g. "d"). See Details.
  maxwidth : float, default=None
      Control the maximum width the points can spread into.
      Values should be in the range (0, 1).
  adjust : float, default=1
      Adjusts the bandwidth of the density kernel when
      `method="density"`. see [](`~plotnine.stats.stat_density`).
  bw : str | float, default="nrd0"
      The bandwidth to use, If a float is given, it is the bandwidth.
      The `str`{.py} choices are:
      `"nrd0", "normal_reference", "scott", "silverman"`{.py}
  
      `nrd0` is a port of `stats::bw.nrd0` in R; it is eqiuvalent
      to `silverman` when there is more than 1 value in a group.
  bin_limit : int, default=1
      If the samples within the same y-axis bin are more
      than `bin_limit`, the samples's X coordinates will be adjusted.
      This parameter is effective only when `method='counts'`{.py}
  random_state : int | ~numpy.random.RandomState, default=None
      Seed or Random number generator to use. If `None`, then
      numpy global generator :class:`numpy.random` is used.
  scale : Literal["area", "count", "width"], default="area"
      How to scale the sina groups.
  
      - `area` - Scale by the largest density/bin among the different sinas
      - `count` - areas are scaled proportionally to the number of points
      - `width` - Only scale according to the maxwidth parameter.
  
  See Also
  --------
  plotnine.geoms.geom_sina
code: def compute_group(cls, data, scales, **params):
      maxwidth = params["maxwidth"]
      bins = params["bins"]
      bin_limit = params["bin_limit"]
      weight = None
      y = data["y"]
  
      if len(data) == 0:
          return pd.DataFrame()
  
      elif len(data) < 3:
          data["density"] = 0
          data["scaled"] = 1
      elif len(np.unique(y)) < 2:
          data["density"] = 1
          data["scaled"] = 1
      elif params["method"] == "density":
          from scipy.interpolate import interp1d
  
          # density kernel estimation
          range_y = y.min(), y.max()
          dens = compute_density(y, weight, range_y, **params)
          densf = interp1d(
              dens["x"],
              dens["density"],
              bounds_error=False,
              fill_value="extrapolate",  # pyright: ignore
          )
          data["density"] = densf(y)
          data["scaled"] = data["density"] / dens["density"].max()
      else:
          # bin based estimation
          bin_index = pd.cut(y, bins, include_lowest=True, labels=False)
          data["density"] = (
              pd.Series(bin_index)
              .groupby(bin_index)
              .apply(len)[bin_index]
              .to_numpy()
          )
          data.loc[data["density"] <= bin_limit, "density"] = 0
          data["scaled"] = data["density"] / data["density"].max()
  
      # Compute width if x has multiple values
      if len(data["x"].unique()) > 1:
          width = np.ptp(data["x"]) * maxwidth
      else:
          width = maxwidth
  
      data["width"] = width
      data["n"] = len(data)
      data["x"] = np.mean([data["x"].max(), data["x"].min()])
  
      return data
  
file_path: plotnine/plotnine/stats/stat_sina.py
imports: import numpy
  import pandas
  from .._utils import array_kind, jitter, resolution
  from ..doctools import document
  from ..exceptions import PlotnineError
  from ..mapping.aes import has_groups
  from .binning import breaks_from_bins, breaks_from_binwidth
  from .stat import stat
  from .stat_density import compute_density
label_desc: Use image node_id 4 for calling the stat_sina obj's underlying member method code with example usage: obj.compute_group(cls, data, scales) and returns: data, pd