Stochastic systems additions by murrayrm · Pull Request #714 · python-control/python-control

Sorry to jump in a little late here...

Doesn't white_noise scale Q the wrong way for a continuous-time system? Right now it scales the standard deviation by 1/sqrt(dt). But it should scale by sqrt(dt) for the integral of the covariance to be Q over the simulation sample time (hence the noise integral from 0 to dt, and the std deviation, should decrease to 0 as dt-->0, instead of increasing to infinity).

Also, since this is generating multivariate noise, why not allow Q to be a covariance matrix with correlations between variables? This can be done by eg:

Q = np.array(Q)
if Q.ndim == 0:
    # scalar
    Q = np.ones((1,1), dtype = np.float64)*Q
    
elif Q.ndim == 1:
    # uncorrelated signals: diagonal covariance matrix
    Q = np.diag(Q)
    
elif Q.ndim == 2:
    # full covariance matrix
    if Q.shape[0] != Q.shape[1]:
        raise ValueError("Noise covariance matrix is not square!")
else:
    # error
    raise ValueError("Noise covariance matrix has >2 dimensions!")

means = np.zeros((Q.shape[0],), dtype = np.float64)
W = rng.multivariate_normal(means, Q*np.sqrt(dt), size = T.size, method = "cholesky")