コード例 #1
0
def fInitialise(pRng):
    """
    A function to initialise particles

    param: pRng[smctc.rng] A pointer to the random number generator which is to be used
    """
    value = [0.0]*4 # cv_state
  
    value[0] = pRng.Normal(0,sqrt(var_s0)) # x_pos
    value[1] = pRng.Normal(0,sqrt(var_s0)) # y_pos
    value[2] = pRng.Normal(0,sqrt(var_u0)) # x_vel
    value[3] = pRng.Normal(0,sqrt(var_u0)) # y_vel

    return smctc.particle(value,logLikelihood(0,value))
コード例 #2
0
 def test_init_value(self):
     a = smctc.particle([1, 2.0], 2.3)
コード例 #3
0
 def test_init_copy(self):
     a = smctc.particle([1, 2.0], 2.3)
     b = smctc.particle(a)
コード例 #4
0
 def test_init_default(self):
     smctc.particle()
コード例 #5
0
def fInitialise(pRng):
    value = [0.0] * 2  # state
    value[0] = pRng.Normal(0, 1)  # pos
    value[1] = pRng.Normal(0, 1)  # vel
    return smctc.particle(value, 1.0)
コード例 #6
0
 def test_DoMove(self):
     a = smctc.particle([1, 2.0], 2.3)
     mrng = smctc.rng()
     fmove = smctc.moveset(fInitialise, fMove)
     fmove.DoMove(0, a, mrng)
     self.assertAlmostEqual(a.GetLogWeight(), 2.4)
コード例 #7
0
 def test_set_value(self):
     a = smctc.particle([1, 2.0], 2.3)
     a.SetValue([1, 2.0])
     self.assertEqual(a.GetValue(), [1, 2.0])
コード例 #8
0
 def test_set_log_weight(self):
     a = smctc.particle([1, 2.0], 2.3)
     a.SetLogWeight(2.3)
     self.assertEqual(a.GetLogWeight(), 2.3)