code: def uu_chi2(n, m):
      """Normalized Chi^2 formula for two histograms with different number of entries
  
      Copyright ROOT:
      Formulas translated from c++ to python, but formulas otherwise not modified.
      Reference: https://root.cern.ch/doc/master/classTH1.html#a6c281eebc0c0a848e7a0d620425090a5
      GNU License: https://root.cern.ch/license
      All modifications copyright INGA WB.
  
      :param n: 1d array with bin counts of the reference set
      :param m: 1d array with bin counts of the test set
      :return: tuple of floats (chi2_value, chi2_norm, z_score, p_value, res)
      """
  
      def _not_finite_to_zero(x):
          res = x.copy()
          res[~np.isfinite(res)] = 0
          return res
  
      if len(n) == 0 or len(m) == 0:
          raise ValueError("Input histogram(s) has zero size.")
      if len(n) != len(m):
          raise ValueError("Input histograms have unequal size.")
  
      N = np.sum(n)  # noqa: N806
      M = np.sum(m)  # noqa: N806
  
      if N == 0 or M == 0:
          return np.nan, np.nan, np.nan, np.nan, [0] * len(n)
  
      # remove all zero entries in the sum, to present division by zero for individual bins
      z = n + m
      n = n[z != 0]
      m = m[z != 0]
  
      dof = ((n != 0) | (m != 0)).sum() - 1
      chi2_value = (
          _not_finite_to_zero(((M * n - N * m) ** 2) / (n + m)).sum()
          / M
          / N
      )
  
      chi2_norm = chi2_value / dof if dof > 0 else np.nan
      p_value = stats.chi2.sf(chi2_value, dof)
      z_score = -stats.norm.ppf(p_value)
  
      p = (n + m) / (N + M)
  
      if (p == 1).any():
          # unusual case of (only) one bin with p==1, avoids division with zero below
          res = np.array([np.nan] * len(p))
      else:
          res = _not_finite_to_zero(
              (n - N * p)
              / np.sqrt(N * p)
              / np.sqrt((1 - N / (N + M)) * (1 - p))
          )
  
      return chi2_value, chi2_norm, z_score, p_value, res
  
file_path: popmon/popmon/analysis/comparison/comparisons.py
imports: import numpy
  from scipy import stats
  from popmon.base.registry import Registry
label_desc: Use image node_id 10 for calling a global function with example usage: uu_chi2(n, m) and returns: chi2_value,  chi2_norm,  z_score,  p_value,  res, res, np,  np,  np,  np,  unknown