code: def compute_effsize(x, y, paired=False, eftype="cohen"):
      """Calculate effect size between two set of observations.
  
      Parameters
      ----------
      x : np.array or list
          First set of observations.
      y : np.array or list
          Second set of observations.
      paired : boolean
          If True, uses Cohen d-avg formula to correct for repeated measurements
          (see Notes).
      eftype : string
          Desired output effect size.
          Available methods are:
  
          * ``'none'``: no effect size
          * ``'cohen'``: Unbiased Cohen d
          * ``'hedges'``: Hedges g
          * ``'r'``: Pearson correlation coefficient
          * ``'pointbiserialr'``: Point-biserial correlation
          * ``'eta-square'``: Eta-square
          * ``'odds-ratio'``: Odds ratio
          * ``'AUC'``: Area Under the Curve
          * ``'CLES'``: Common Language Effect Size
  
      Returns
      -------
      ef : float
          Effect size
  
      See Also
      --------
      convert_effsize : Conversion between effect sizes.
      compute_effsize_from_t : Convert a T-statistic to an effect size.
  
      Notes
      -----
      Missing values are automatically removed from the data. If ``x`` and ``y`` are paired, the
      entire row is removed.
  
      If ``x`` and ``y`` are independent, the Cohen :math:`d` is:
  
      .. math::
  
          d = \\frac{\\overline{X} - \\overline{Y}}
          {\\sqrt{\\frac{(n_{1} - 1)\\sigma_{1}^{2} + (n_{2} - 1)
          \\sigma_{2}^{2}}{n1 + n2 - 2}}}
  
      If ``x`` and ``y`` are paired, the Cohen :math:`d_{avg}` is computed:
  
      .. math::
  
          d_{avg} = \\frac{\\overline{X} - \\overline{Y}}
          {\\sqrt{\\frac{(\\sigma_1^2 + \\sigma_2^2)}{2}}}
  
      The Cohen's d is a biased estimate of the population effect size, especially for small samples
      (n < 20). It is often preferable to use the corrected Hedges :math:`g` instead:
  
      .. math:: g = d \\times (1 - \\frac{3}{4(n_1 + n_2) - 9})
  
      The common language effect size is the proportion of pairs where ``x`` is higher than ``y``
      (calculated with a brute-force approach where each observation of ``x`` is paired to each
      observation of ``y``, see :py:func:`pingouin.wilcoxon` for more details):
  
      .. math:: \\text{CL} = P(X > Y) + .5 \\times P(X = Y)
  
      For other effect sizes, Pingouin will first calculate a Cohen :math:`d` and then use the
      :py:func:`pingouin.convert_effsize` to convert to the desired effect size.
  
      References
      ----------
      * Lakens, D., 2013. Calculating and reporting effect sizes to
        facilitate cumulative science: a practical primer for t-tests and
        ANOVAs. Front. Psychol. 4, 863. https://doi.org/10.3389/fpsyg.2013.00863
  
      * Cumming, Geoff. Understanding the new statistics: Effect sizes,
        confidence intervals, and meta-analysis. Routledge, 2013.
  
      * https://osf.io/vbdah/
  
      Examples
      --------
      1. Cohen d from two independent samples.
  
      >>> import numpy as np
      >>> import pingouin as pg
      >>> x = [1, 2, 3, 4]
      >>> y = [3, 4, 5, 6, 7]
      >>> pg.compute_effsize(x, y, paired=False, eftype='cohen')
      -1.707825127659933
  
      The sign of the Cohen d will be opposite if we reverse the order of
      ``x`` and ``y``:
  
      >>> pg.compute_effsize(y, x, paired=False, eftype='cohen')
      1.707825127659933
  
      2. Hedges g from two paired samples.
  
      >>> x = [1, 2, 3, 4, 5, 6, 7]
      >>> y = [1, 3, 5, 7, 9, 11, 13]
      >>> pg.compute_effsize(x, y, paired=True, eftype='hedges')
      -0.8222477210374874
  
      3. Common Language Effect Size.
  
      >>> pg.compute_effsize(x, y, eftype='cles')
      0.2857142857142857
  
      In other words, there are ~29% of pairs where ``x`` is higher than ``y``,
      which means that there are ~71% of pairs where ``x`` is *lower* than ``y``.
      This can be easily verified by changing the order of ``x`` and ``y``:
  
      >>> pg.compute_effsize(y, x, eftype='cles')
      0.7142857142857143
      """
      # Check arguments
      if not _check_eftype(eftype):
          err = f"Could not interpret input '{eftype}'"
          raise ValueError(err)
  
      x = np.asarray(x)
      y = np.asarray(y)
  
      if x.size != y.size and paired:
          warnings.warn(
              "x and y have unequal sizes. Switching to "
              "paired == False."
          )
          paired = False
  
      # Remove rows with missing values
      x, y = remove_na(x, y, paired=paired)
      nx, ny = x.size, y.size
  
      if ny == 1:
          # Case 1: One-sample Test
          d = (x.mean() - y) / x.std(ddof=1)
          return d
      if eftype.lower() == "r":
          # Return correlation coefficient (useful for CI bootstrapping)
          r, _ = pearsonr(x, y)
          return r
      elif eftype.lower() == "cles":
          # Compute exact CLES (see pingouin.wilcoxon)
          diff = x[:, None] - y
          return np.where(diff == 0, 0.5, diff > 0).mean()
      else:
          # Compute unbiased Cohen's d effect size
          if not paired:
              # https://en.wikipedia.org/wiki/Effect_size
              dof = nx + ny - 2
              poolsd = np.sqrt(
                  ((nx - 1) * x.var(ddof=1) + (ny - 1) * y.var(ddof=1))
                  / dof
              )
              d = (x.mean() - y.mean()) / poolsd
          else:
              # Report Cohen d-avg (Cumming 2012; Lakens 2013)
              # Careful, the formula in Lakens 2013 is wrong. Updated in Pingouin
              # v0.3.4 to use the formula provided by Cummings 2012.
              # Before that the denominator was just (SD1 + SD2) / 2
              d = (x.mean() - y.mean()) / np.sqrt(
                  (x.var(ddof=1) + y.var(ddof=1)) / 2
              )
          return convert_effsize(d, "cohen", eftype, nx=nx, ny=ny)
  
file_path: pingouin/pingouin/effsize.py
imports: import warnings
  import numpy
  from scipy.stats import pearsonr
  from pingouin.utils import _check_eftype, remove_na
label_desc: Use image node_id 4 for calling a global function with example usage: compute_effsize(x, y, paired, eftype) and returns: d, r, np, convert_effsize