code: def circ_rayleigh(angles, w=None, d=None):
      """Rayleigh test for non-uniformity of circular data.
  
      Parameters
      ----------
      angles : 1-D array_like
          Samples of angles in radians. The range of ``angles`` must be either
          :math:`[0, 2\\pi]` or :math:`[-\\pi, \\pi]`. If ``angles`` is not
          expressed in radians (e.g. degrees or 24-hours), please use the
          :py:func:`pingouin.convert_angles` function prior to using the present
          function.
      w : array_like
          Number of incidences per bins (i.e. "weights"), in case of binned angle
          data.
      d : float
          Spacing (in radians) of bin centers for binned data. If supplied,
          a correction factor is used to correct for bias in the estimation
          of r.
  
      Returns
      -------
      z : float
          Z-statistic
      pval : float
          P-value
  
      Notes
      -----
      The Rayleigh test asks how large the resultant vector length R must be
      to indicate a non-uniform  distribution (Fisher 1995).
  
      H0: the population is uniformly distributed around the circle
      HA: the populatoin is not distributed uniformly around the circle
  
      The assumptions for the Rayleigh test are that (1) the distribution has
      only one mode and (2) the data is sampled from a von Mises distribution.
  
      Examples
      --------
      1. Simple Rayleigh test for non-uniformity of circular data.
  
      >>> from pingouin import circ_rayleigh
      >>> x = [0.785, 1.570, 3.141, 0.839, 5.934]
      >>> z, pval = circ_rayleigh(x)
      >>> print(round(z, 3), round(pval, 6))
      1.236 0.304844
  
      2. Specifying w and d
  
      >>> z, pval = circ_rayleigh(x, w=[.1, .2, .3, .4, .5], d=0.2)
      >>> print(round(z, 3), round(pval, 6))
      0.278 0.806997
      """
      angles = np.asarray(angles)
      _checkangles(angles)  # Check that angles is in radians
      if w is None:
          r = circ_r(angles)
          n = len(angles)
      else:
          assert len(angles) == len(w), "Input dimensions do not match"
          r = circ_r(angles, w, d)
          n = np.sum(w)
  
      # Compute Rayleigh's statistic
      R = n * r
      z = (R**2) / n
  
      # Compute p value using approxation in Zar (1999), p. 617
      pval = np.exp(
          np.sqrt(1 + 4 * n + 4 * (n**2 - R**2)) - (1 + 2 * n)
      )
      return z, pval
  
file_path: pingouin/pingouin/circular.py
imports: import numpy
  from scipy.stats import norm
  from .utils import remove_na
label_desc: Use image node_id 8 for calling a global function with example usage: circ_rayleigh(angles, w, d) and returns: z,  pval