pykoop.random_state

random_state(low, high, rng=None)

Generate a random initial state.

Generates uniform random data between specified bounds.

Very simply wrapper. Really only exists to keep a common interface with random_input, which is much more complex.

Parameters:
  • low (float or (n, 1) np.ndarray) – Lower bound for uniform random distribution.

  • high (float or (n, 1) np.ndarray) – Upper bound for uniform random distribution.

  • rng (Optional[Generator]) – Random number generator, numpy.random.default_rng(seed).

Returns:

Random initial state.

Return type:

np.ndarray

Examples

Simulate a mass-spring-damper with random initial condition

>>> x_max = np.array([1, 1])
>>> x0 = pykoop.random_state(-x_max, x_max)
>>> t, x = msd.simulate((0, 1), 1e-3, x0, lambda t: 0)