code: def test_beta_bernoulli(self):
      print()
      logger.info("test_beta_bernoulli\n" + "-" * 80 + "\n")
      for theta in [0.21, 0.5, 0.93]:
          data = np.random.rand(1000) < theta
          theta_hat = (1 + sum(data)) / (len(data) + 2)
          dist_np = BetaBernoulli()
          dist_np.update(data)
          self.assertEqual(dist_np.alpha, 1 + sum(data))
          self.assertEqual(dist_np.beta, 1 + sum(1 - data))
          pred = dist_np.posterior([0, 1], log=False)
          expected = np.asarray([1 - theta_hat, theta_hat])
          self.assertAlmostEqual(
              np.max(np.abs(pred - expected)), 0, places=6
          )
  
          ts = TimeSeries.from_pd(data, freq="MS")
          dist_ts = BetaBernoulli(ts[:30])
          dist_ts.update(ts[30:])
          self.assertEqual(dist_ts.alpha, 1 + sum(data))
          self.assertEqual(dist_ts.beta, 1 + sum(1 - data))
          pred = dist_ts.posterior(
              TimeSeries.from_pd([0, 1]), log=False
          )
          self.assertAlmostEqual(
              np.max(np.abs(pred - expected)), 0, places=6
          )
  
file_path: merlion/tests/change_point/test_conj_prior.py
imports: import logging
  from packaging import version
  import sys
  import unittest
  import numpy
  import scipy
  from merlion.utils.conj_priors import BetaBernoulli, NormInvGamma, MVNormInvWishart, BayesianLinReg, BayesianMVLinReg
  from merlion.utils.time_series import TimeSeries, UnivariateTimeSeries
label_desc: Use image node_id 2 for calling the TestConjugatePriors obj's underlying member method code with example usage: obj.test_beta_bernoulli() without return types