Discretize Continuous State Space Model
Implement a discretization method for State Space Models originally defined in continuous time to accommodate discrete token sequences. This process is crucial for applying continuous-time models to real-world problems that involve discrete data.
The Continuous State Space Model is defined by the equations and , where is the state vector, is the input vector, and is the output vector. To discretize this model, we can use the Zero-Order Hold method, which assumes the input is constant between sampling times.
Here are the steps to discretize the model:
- Define the continuous-time model parameters , , and the sampling time .
- Compute the discretized state transition matrix and input coefficient .
When the fraction for is undefined; use its limit instead, (and ).
Return the tuple with both values rounded to 4 decimal places.
This technique is widely used in digital control systems.
Example
A=-1.0, B=1.0, delta=0.1
(0.9048, 0.0952)
- Inputs:
Ais the continuous decay rate of the state,Bscales how strongly the input pushes the state, anddeltais the time between two tokens. - State transition: over one step the state decays by the factor , which rounds to .
- Input coefficient: with the input held constant for the whole step, , which rounds to .
- Output: the pair
(0.9048, 0.0952), so one step of the discrete model reads : about 9.5% of the old state fades and roughly that much input is absorbed. - Notice: is close to . For small the fraction approaches , and that limit is exactly the value takes when .
Constraints
- : Continuous state transition (scalar),
- : Input coefficient (scalar),
- : Discretization step size,