code: def test_statistics_1():
      a, w = get_data()
      _means = np.zeros((3, 1, 1, 6))
      _weights = np.zeros((3, 1, 1, 6))
      for i, j, k, l in itertools.product(
          range(a.shape[0]),
          range(a.shape[1]),
          range(a.shape[2]),
          range(a.shape[3]),
      ):
          _means[i, 0, 0, l] += w[i, j, k, l] * a[i, j, k, l]
          _weights[i, 0, 0, l] += w[i, j, k, l]
      _means /= _weights
      np.testing.assert_allclose(
          _means, mean(a, w, axis=(1, 2), keepdims=True), rtol=1e-07
      )
      _stds = np.zeros((3, 1, 1, 6))
      for i, j, k, l in itertools.product(
          range(a.shape[0]),
          range(a.shape[1]),
          range(a.shape[2]),
          range(a.shape[3]),
      ):
          _stds[i, 0, 0, l] += (
              w[i, j, k, l] * (a[i, j, k, l] - _means[i, 0, 0, l]) ** 2
          )
      _stds = np.sqrt(_stds / _weights)
      np.testing.assert_allclose(
          _stds, std(a, w, axis=(1, 2), keepdims=True), rtol=1e-07
      )
      _values = np.zeros((3, 6, 4 * 5))
      _weights = np.zeros((3, 6, 4 * 5))
      for i, j, k, l in itertools.product(
          range(a.shape[0]),
          range(a.shape[1]),
          range(a.shape[2]),
          range(a.shape[3]),
      ):
          _values[i, l, j * a.shape[2] + k] = a[i, j, k, l]
          _weights[i, l, j * a.shape[2] + k] = w[i, j, k, l]
  
      def get_quantiles(q):
          _quantiles = np.zeros((3, 6))
          for i in range(a.shape[0]):
              for ll in range(a.shape[3]):
                  isort = np.argsort(_values[i, ll])
                  v = _values[i, ll][isort]
                  u = _weights[i, ll][isort]
                  U = u.cumsum()
                  r = (U - 0.5 * u) / U[-1]
                  for m in range(1, len(u)):
                      if r[m - 1] <= q and r[m] > q:
                          _quantiles[i, ll] = v[m - 1] + (
                              q - r[m - 1]
                          ) / (r[m] - r[m - 1]) * (v[m] - v[m - 1])
                          break
          return _quantiles
  
      np.testing.assert_allclose(
          get_quantiles(0.1),
          quantile(a, 0.1, w, axis=(1, 2), keepdims=False),
          rtol=1e-07,
      )
      np.testing.assert_allclose(
          get_quantiles(0.5),
          quantile(a, 0.5, w, axis=(1, 2), keepdims=False),
          rtol=1e-07,
      )
      np.testing.assert_allclose(
          get_quantiles(0.9),
          quantile(a, 0.9, w, axis=(1, 2), keepdims=False),
          rtol=1e-07,
      )
  
file_path: popmon/tests/popmon/stats/test_numpy.py
imports: import itertools
  import numpy
  from scipy import linalg, stats
  from popmon.stats.numpy import mean, probability_distribution_mean_covariance, quantile, std
label_desc: Use image node_id 5 for calling a global function with example usage: test_statistics_1() and returns: _quantiles