class_docstr: Unit test class for general utilities. 
class_docstr_tok: ["Unit","test","class","for","general","utilities","."]
docstr: Tests for draw gaussian samples. 
docstr_tok: ["Tests","for","draw","gaussian","samples","."]
code: def test_draw_gaussian_samples(self):
      """Tests for draw gaussian samples."""
      self.report(
          "draw_gaussian_samples. Probabilistic test, could fail at times"
      )
      num_samples = 10000
      num_pts = 3
      mu = list(range(num_pts))
      K = np.random.normal(size=(num_pts, num_pts))
      K = K.dot(K.T)
      samples = general_utils.draw_gaussian_samples(num_samples, mu, K)
      sample_mean = samples.mean(axis=0)
      sample_centralised = samples - sample_mean
      sample_covar = (
          sample_centralised.T.dot(sample_centralised) / num_samples
      )
      mean_tol = 4 * np.linalg.norm(mu) / np.sqrt(num_samples)
      covar_tol = 4 * np.linalg.norm(K) / np.sqrt(num_samples)
      mean_err = np.linalg.norm(mu - sample_mean)
      covar_err = np.linalg.norm(K - sample_covar)
      self.report(
          "Mean error (tol): "
          + str(mean_err)
          + " ("
          + str(mean_tol)
          + ")",
          "test_result",
      )
      self.report(
          "Cov error (tol): "
          + str(covar_err)
          + " ("
          + str(covar_tol)
          + ")",
          "test_result",
      )
      assert mean_err < mean_tol
      assert covar_err < covar_tol
  
file_path: dragonfly/dragonfly/utils/unittest_general_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  import numpy
  from .None import general_utils
  from .base_test_class import BaseTestClass, execute_tests
label_desc: Use image node_id 7 for calling the GeneralUtilsTestCase obj's underlying member method code with example usage: obj.test_draw_gaussian_samples() without return types