def prepare_data(dt, num_steps, num_observers): y_recs = [] for i in range(num_observers): print_flush("Generating simulation sequences {}/{}".format( i, num_observers)) sm = StateSpaceModel2Dim(n_dim=2, A=A0, g=fn.LinearFn(utils.zeros(2)), sigma_w=0.1, sigma_z=0.1, x=mu0[0], y=utils.zeros((1, 2))) sm.dt = dt (x_rec, y_rec) = sm.simulation(num_steps, dt) y_recs.append(y_rec) return y_recs
def test_init_val(self): actual_mu = self.s.data["mu"] expected_mu = utils.zeros(self.n) self.assertIsNone(np.testing.assert_array_equal(expected_mu, actual_mu)) actual_sigma = self.s.data["sigma"] expected_sigma = np.diag(np.eye(self.n, dtype=np.float32)) self.assertIsNone(np.testing.assert_array_equal(expected_sigma, actual_sigma))
# print("===Starting UnitTest01===") # print("-- A simple test of Bundle with no Matcher") # plt.figure(1) # test_BundleEKFContinuousTime01(dt, n_steps) # plt.pause(0.2) dt = 0.02 n_steps = 500 # preparing a list of three simulation sequences yrecs = [] for i in range(1): sm = StateSpaceModel2Dim(n_dim=2, A=np.array([[-0.1, 2], [-2, -0.1]], dtype=np.float32), g=fn.LinearFn(utils.zeros(2)), sigma_w=0.1, sigma_z=0.1, x=np.array([0, 0], dtype=np.float32), y=utils.zeros((1, 2))) sm.A = A0 sm.x = mu0 sm.dt = dt (x_rec, y_rec) = sm.simulation(n_steps, dt) yrecs.append(y_rec) plt.figure(0) for i in range(1): plt.subplot(2, 2, i + 1) plt.scatter(yrecs[i][:, 0], yrecs[i][:, 1], s=2) plt.title("sequence {}".format(i))
def test_init_val(self): actual = self.b0.state.data["mu"] expected = utils.zeros(self.n) self.assertIsNone(np.testing.assert_array_equal(expected, actual))