コード例 #1
0
def test_Z2():
  """ Test of implementation 2. """
  traj = simple_traj2()
  theta = np.array([0.0, -1.0])
  choices = [0, 1]
  elts = LearningElements(traj, theta, choices)
  elts.computeLogZ()
  elts_ref = LearningElementsRef(traj, theta, choices)
  elts_ref.computeLogZ()
  assert(within(elts.logZ, elts_ref.logZ, 1e-5))
コード例 #2
0
def test_traj_5_1():
  """ test_traj_5_1 """
  traj = simple_traj5()
  theta = np.array([-1.0])
  choices = [1, 0, 2]
  elts = LearningElements(traj, theta, choices)
  elts.computeLogZ()
  elts_ref = LearningElementsRef(traj, theta, choices)
  elts_ref.computeLogZ()
  assert(within(elts.Z, elts_ref.Z, 1e-5)), (elts.Z, elts_ref.Z, 1e-5)
  assert(within(elts.logZ, elts_ref.logZ, 1e-5)), \
    (elts.logZ, elts_ref.logZ, 1e-5)