Discretization

From HandWiki
Revision as of 17:13, 6 February 2024 by JStaso (talk | contribs) (fixing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Process of transferring continuous functions into discrete counterparts
A solution to a discretized partial differential equation, obtained with the finite element method.

In applied mathematics, discretization is the process of transferring continuous functions, models, variables, and equations into discrete counterparts. This process is usually carried out as a first step toward making them suitable for numerical evaluation and implementation on digital computers. Dichotomization is the special case of discretization in which the number of discrete classes is 2, which can approximate a continuous variable as a binary variable (creating a dichotomy for modeling purposes, as in binary classification).

Discretization is also related to discrete mathematics, and is an important component of granular computing. In this context, discretization may also refer to modification of variable or category granularity, as when multiple discrete variables are aggregated or multiple discrete categories fused.

Whenever continuous data is discretized, there is always some amount of discretization error. The goal is to reduce the amount to a level considered negligible for the modeling purposes at hand.

The terms discretization and quantization often have the same denotation but not always identical connotations. (Specifically, the two terms share a semantic field.) The same is true of discretization error and quantization error.

Mathematical methods relating to discretization include the Euler–Maruyama method and the zero-order hold.

Discretization of linear state space models

Discretization is also concerned with the transformation of continuous differential equations into discrete difference equations, suitable for numerical computing.

The following continuous-time state space model

[math]\displaystyle{ \dot{\mathbf{x}}(t) = \mathbf A \mathbf{x}(t) + \mathbf B \mathbf{u}(t) + \mathbf{w}(t) }[/math]
[math]\displaystyle{ \mathbf{y}(t) = \mathbf C \mathbf{x}(t) + \mathbf D \mathbf{u}(t) + \mathbf{v}(t) }[/math]

where v and w are continuous zero-mean white noise sources with power spectral densities

[math]\displaystyle{ \mathbf{w}(t) \sim N(0,\mathbf Q) }[/math]
[math]\displaystyle{ \mathbf{v}(t) \sim N(0,\mathbf R) }[/math]

can be discretized, assuming zero-order hold for the input u and continuous integration for the noise v, to

[math]\displaystyle{ \mathbf{x}[k+1] = \mathbf A_d \mathbf{x}[k] + \mathbf B_d \mathbf{u}[k] + \mathbf{w}[k] }[/math]
[math]\displaystyle{ \mathbf{y}[k] = \mathbf C_d \mathbf{x}[k] + \mathbf D_d \mathbf{u}[k] + \mathbf{v}[k] }[/math]

with covariances

[math]\displaystyle{ \mathbf{w}[k] \sim N(0,\mathbf Q_d) }[/math]
[math]\displaystyle{ \mathbf{v}[k] \sim N(0,\mathbf R_d) }[/math]

where

[math]\displaystyle{ \mathbf A_d = e^{\mathbf A T} = \mathcal{L}^{-1}\{(s\mathbf I - \mathbf A)^{-1}\}_{t=T} }[/math]
[math]\displaystyle{ \mathbf B_d = \left( \int_{\tau=0}^{T}e^{\mathbf A \tau}d\tau \right) \mathbf B = \mathbf A^{-1}(\mathbf A_d - I)\mathbf B }[/math], if [math]\displaystyle{ \mathbf A }[/math] is nonsingular
[math]\displaystyle{ \mathbf C_d = \mathbf C }[/math]
[math]\displaystyle{ \mathbf D_d = \mathbf D }[/math]
[math]\displaystyle{ \mathbf Q_d = \int_{\tau=0}^{T} e^{\mathbf A \tau} \mathbf Q e^{\mathbf A^\top \tau} d\tau }[/math]
[math]\displaystyle{ \mathbf R_d = \mathbf R \frac{1}{T} }[/math]

and [math]\displaystyle{ T }[/math] is the sample time, although [math]\displaystyle{ \mathbf A^\top }[/math] is the transposed matrix of [math]\displaystyle{ \mathbf A }[/math]. The equation for the discretized measurement noise is a consequence of the continuous measurement noise being defined with a power spectral density.[1]

A clever trick to compute Ad and Bd in one step is by utilizing the following property:[2]:p. 215

[math]\displaystyle{ e^{\begin{bmatrix} \mathbf{A} & \mathbf{B} \\ \mathbf{0} & \mathbf{0} \end{bmatrix} T} = \begin{bmatrix} \mathbf{A_{d}} & \mathbf{B_{d}} \\ \mathbf{0} & \mathbf{I} \end{bmatrix} }[/math]

Where [math]\displaystyle{ \mathbf A_d }[/math]and [math]\displaystyle{ \mathbf B_d }[/math]are the discretized state-space matrices.

Discretization of process noise

Numerical evaluation of [math]\displaystyle{ \mathbf{Q}_d }[/math] is a bit trickier due to the matrix exponential integral. It can, however, be computed by first constructing a matrix, and computing the exponential of it[3]

[math]\displaystyle{ \mathbf{F} = \begin{bmatrix} -\mathbf{A} & \mathbf{Q} \\ \mathbf{0} & \mathbf{A}^\top \end{bmatrix} T }[/math]
[math]\displaystyle{ \mathbf{G} = e^\mathbf{F} = \begin{bmatrix} \dots & \mathbf{A}_d^{-1}\mathbf{Q}_d \\ \mathbf{0} & \mathbf{A}_d^\top \end{bmatrix}. }[/math]

The discretized process noise is then evaluated by multiplying the transpose of the lower-right partition of G with the upper-right partition of G:

[math]\displaystyle{ \mathbf{Q}_d = (\mathbf{A}_d^\top)^\top (\mathbf{A}_d^{-1}\mathbf{Q}_d) = \mathbf{A}_d (\mathbf{A}_d^{-1}\mathbf{Q}_d). }[/math]

Derivation

Starting with the continuous model

[math]\displaystyle{ \mathbf{\dot{x}}(t) = \mathbf A\mathbf x(t) + \mathbf B \mathbf u(t) }[/math]

we know that the matrix exponential is

[math]\displaystyle{ \frac{d}{dt}e^{\mathbf At} = \mathbf A e^{\mathbf At} = e^{\mathbf At} \mathbf A }[/math]

and by premultiplying the model we get

[math]\displaystyle{ e^{-\mathbf At} \mathbf{\dot{x}}(t) = e^{-\mathbf At} \mathbf A\mathbf x(t) + e^{-\mathbf At} \mathbf B\mathbf u(t) }[/math]

which we recognize as

[math]\displaystyle{ \frac{d}{dt}(e^{-\mathbf At}\mathbf x(t)) = e^{-\mathbf At} \mathbf B\mathbf u(t) }[/math]

and by integrating..

[math]\displaystyle{ e^{-\mathbf At}\mathbf x(t) - e^0\mathbf x(0) = \int_0^t e^{-\mathbf A\tau}\mathbf B\mathbf u(\tau) d\tau }[/math]
[math]\displaystyle{ \mathbf x(t) = e^{\mathbf At}\mathbf x(0) + \int_0^t e^{\mathbf A(t-\tau)} \mathbf B\mathbf u(\tau) d \tau }[/math]

which is an analytical solution to the continuous model.

Now we want to discretise the above expression. We assume that u is constant during each timestep.

[math]\displaystyle{ \mathbf x[k] \ \stackrel{\mathrm{def}}{=}\ \mathbf x(kT) }[/math]
[math]\displaystyle{ \mathbf x[k] = e^{\mathbf AkT}\mathbf x(0) + \int_0^{kT} e^{\mathbf A(kT-\tau)} \mathbf B\mathbf u(\tau) d \tau }[/math]
[math]\displaystyle{ \mathbf x[k+1] = e^{\mathbf A(k+1)T}\mathbf x(0) + \int_0^{(k+1)T} e^{\mathbf A((k+1)T-\tau)} \mathbf B\mathbf u(\tau) d \tau }[/math]
[math]\displaystyle{ \mathbf x[k+1] = e^{\mathbf AT} \left[ e^{\mathbf AkT}\mathbf x(0) + \int_0^{kT} e^{\mathbf A(kT-\tau)} \mathbf B\mathbf u(\tau) d \tau \right]+ \int_{kT}^{(k+1)T} e^{\mathbf A(kT+T-\tau)} \mathbf B\mathbf u(\tau) d \tau }[/math]

We recognize the bracketed expression as [math]\displaystyle{ \mathbf x[k] }[/math], and the second term can be simplified by substituting with the function [math]\displaystyle{ v(\tau) = kT + T - \tau }[/math]. Note that [math]\displaystyle{ d\tau=-dv }[/math]. We also assume that [math]\displaystyle{ \mathbf u }[/math] is constant during the integral, which in turn yields

[math]\displaystyle{ \begin{matrix} \mathbf x[k+1]&=& e^{\mathbf AT}\mathbf x[k] - \left( \int_{v(kT)}^{v((k+1)T)} e^{\mathbf Av} dv \right) \mathbf B\mathbf u[k] \\ &=& e^{\mathbf AT}\mathbf x[k] - \left( \int_T^0 e^{\mathbf Av} dv \right) \mathbf B\mathbf u[k] \\ &=& e^{\mathbf AT}\mathbf x[k] + \left( \int_0^T e^{\mathbf Av} dv \right) \mathbf B\mathbf u[k] \\ &=&e^{\mathbf AT}\mathbf x[k] + \mathbf A^{-1}\left(e^{\mathbf AT}-\mathbf I \right) \mathbf B\mathbf u[k] \end{matrix} }[/math]

which is an exact solution to the discretization problem.

When [math]\displaystyle{ \mathbf{A} }[/math] is singular, the latter expression can still be used by replacing [math]\displaystyle{ e^{\mathbf AT} }[/math] by its Taylor expansion,

[math]\displaystyle{ e^{{\mathbf A}T} = \sum_{k=0}^{\infty} \frac{1}{k!} ({\mathbf A}T)^k . }[/math]

This yields

[math]\displaystyle{ \begin{matrix} \mathbf x[k+1]&=& e^{{\mathbf A}T}\mathbf x[k] + \left( \int_0^T e^{{\mathbf A}v} dv \right) \mathbf B\mathbf u[k] \\ &=&\left(\sum_{k=0}^{\infty} \frac{1}{k!} ({\mathbf A}T)^k\right) \mathbf x[k] + \left(\sum_{k=1}^{\infty} \frac{1}{k!} {\mathbf A}^{k-1} T^k\right) \mathbf B\mathbf u[k], \end{matrix} }[/math]

which is the form used in practice.

Approximations

Exact discretization may sometimes be intractable due to the heavy matrix exponential and integral operations involved. It is much easier to calculate an approximate discrete model, based on that for small timesteps [math]\displaystyle{ e^{\mathbf AT} \approx \mathbf I + \mathbf A T }[/math]. The approximate solution then becomes:

[math]\displaystyle{ \mathbf x[k+1] \approx (\mathbf I + \mathbf AT) \mathbf x[k] + T\mathbf B \mathbf u[k] }[/math]

This is also known as the Euler method, which is also known as the forward Euler method. Other possible approximations are [math]\displaystyle{ e^{\mathbf AT} \approx \left( \mathbf I - \mathbf A T \right)^{-1} }[/math], otherwise known as the backward Euler method and [math]\displaystyle{ e^{\mathbf AT} \approx \left( \mathbf I +\frac{1}{2} \mathbf A T \right) \left( \mathbf I - \frac{1}{2} \mathbf A T \right)^{-1} }[/math], which is known as the bilinear transform, or Tustin transform. Each of these approximations has different stability properties. The bilinear transform preserves the instability of the continuous-time system.

Discretization of continuous features

Main page: Discretization of continuous features

In statistics and machine learning, discretization refers to the process of converting continuous features or variables to discretized or nominal features. This can be useful when creating probability mass functions.

Discretization of smooth functions

In generalized functions theory, discretization arises as a particular case of the Convolution Theorem on tempered distributions

[math]\displaystyle{ \mathcal{F}\{f*\operatorname{III}\} = \mathcal{F}\{f\} \cdot \operatorname{III} }[/math]
[math]\displaystyle{ \mathcal{F}\{\alpha \cdot \operatorname{III}\}= \mathcal{F}\{\alpha\}*\operatorname{III} }[/math]

where [math]\displaystyle{ \operatorname{III} }[/math] is the Dirac comb, [math]\displaystyle{ \cdot \operatorname{III} }[/math] is discretization, [math]\displaystyle{ * \operatorname{III} }[/math] is periodization, [math]\displaystyle{ f }[/math] is a rapidly decreasing tempered distribution (e.g. a Dirac delta function [math]\displaystyle{ \delta }[/math] or any other compactly supported function), [math]\displaystyle{ \alpha }[/math] is a smooth, slowly growing ordinary function (e.g. the function that is constantly [math]\displaystyle{ 1 }[/math] or any other band-limited function) and [math]\displaystyle{ \mathcal{F} }[/math] is the (unitary, ordinary frequency) Fourier transform. Functions [math]\displaystyle{ \alpha }[/math] which are not smooth can be made smooth using a mollifier prior to discretization.

As an example, discretization of the function that is constantly [math]\displaystyle{ 1 }[/math] yields the sequence [math]\displaystyle{ [..,1,1,1,..] }[/math] which, interpreted as the coefficients of a linear combination of Dirac delta functions, forms a Dirac comb. If additionally truncation is applied, one obtains finite sequences, e.g. [math]\displaystyle{ [1,1,1,1] }[/math]. They are discrete in both, time and frequency.

See also

References

  1. Analytic Sciences Corporation. Technical Staff. (1974). Applied optimal estimation.. Gelb, Arthur, 1937-. Cambridge, Mass.: M.I.T. Press. pp. 121. ISBN 0-262-20027-9. OCLC 960061. https://archive.org/details/appliedoptimales00agel. 
  2. Raymond DeCarlo: Linear Systems: A State Variable Approach with Numerical Implementation, Prentice Hall, NJ, 1989
  3. Charles Van Loan: Computing integrals involving the matrix exponential, IEEE Transactions on Automatic Control. 23 (3): 395–404, 1978

Further reading

External links