harold.random_state_model

harold.random_state_model(n, p=1, m=1, dt=None, prob_dist=None, stable=True)

Generates a continuous or discrete State model with random data.

The poles of the model is selected from randomly generated numbers with a predefined probability assigned to each pick which can also be provided by external array. The specification of the probability is a simple 5-element array-like [p0, p1, p2, p3] denoting

p0 : Probability of having a real pole
p1 : Probability of having a complex pair anywhere except real line
p2 : Probability of having an integrator (s or z domain)
p3 : Probability of having a pair on the imaginary axis/unit circle

Hence, [1, 0, 0, 0] would return a model with only real poles. Notice that the sum of entries should sum up to 1. See numpy.random.choice for more details. The default probabilities are

[p0, p1, p2, p3] = [0.475, 0.475, 0.025, 0.025]

If stable keyword is set to True prob_dist must be 2-entry arraylike denoting only [p0, p1]. The default is uniform i.e.

[p0, p1] = [0.5, 0.5]
Parameters:
  • n (int) – The number of states. For static models use n=0.
  • p (int, optional) – The number of outputs. The default is 1
  • m (int, optional) – The number of inputs. The default is 1
  • prob_dist (arraylike, optional) – An arraylike with 4 nonnegative entries of which the sum adds up to 1. If stable key is True then it needs only 2 entries. Internally, it uses numpy.random.choice for selection.
  • dt (float, optional) – If dt is not None, then the value will be used as sampling period to create a discrete time model. This argument must be nonnegative.
  • stable (bool, optional) – If True a stable model is returned, otherwise stability model would not be checked
Returns:

G (State) – The resulting State model

Notes

Internally, n, p, m will be converted to integers if possible. This means that no checks about the decimal part will be performed.

Similarly prob_dist will be passed directly to a numpy.ndarray with explicitly taking the real part.

Note that probabilities denote the choice not the distribution of the poles, in other words for a 3-state model, single real pole and a complex pair have the same probability of choice however real pole constitute one third.