Пример #1
0
 def test_ncol(self):
     r = npu.row(429., 5., 2., 14.)
     self.assertEqual(npu.ncol(r), 4)
     c = npu.col(429., 5., 2., 14.)
     self.assertEqual(npu.ncol(c), 1)
     m = npu.matrix_of(3, 5, 0.)
     self.assertEqual(npu.ncol(m), 5)
Пример #2
0
 def __init__(self, process_dim=1, noise_dim=None, drift=None, diffusion=None, **kwargs):
     self._process_dim = process_dim
     self._noise_dim = process_dim if noise_dim is None else noise_dim
     # Note: the brackets around the lambdas below are essential, otherwise the result of the parsing will not be what we need:
     self._drift = (lambda t, x: npu.row_of(self._process_dim, 0.)) if drift is None else drift
     self._diffusion = (lambda t, x: npu.matrix_of(self._process_dim, self._noise_dim, 0.)) if diffusion is None else diffusion
     self._to_string_helper_ItoProcess = None
     self._str_ItoProcess = None
     
     super(ItoProcess, self).__init__(process_dim=self._process_dim, noise_dim=self._noise_dim,
             drift=self._drift, diffusion=self._diffusion, **kwargs)
Пример #3
0
 def test_matrix_of(self):
     matrix = npu.matrix_of(2, 3, 429.)
     npt.assert_almost_equal(matrix, np.array([[429., 429., 429.], [429., 429., 429.]]))