diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 097138c..c2b3015 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-21T21:55:45","documenter_version":"1.6.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-24T21:20:21","documenter_version":"1.6.0"}} \ No newline at end of file diff --git a/dev/api/kf/index.html b/dev/api/kf/index.html index 89d523e..e72dc94 100644 --- a/dev/api/kf/index.html +++ b/dev/api/kf/index.html @@ -1,5 +1,5 @@ -Kalman Filters · SpatiotemporalGPs.jl

Kalman Filter

SpatiotemporalGPs.KalmanFilter.KFStateType
KFState{V, M}

A type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.

source
SpatiotemporalGPs.KalmanFilter.KFStateMethod
KFState(; μ, Σ, make_symmetric=true)

A constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.

source
LinearAlgebra.diagMethod
diag(M::Cholesky)

is a fast method for getting the diagonal of a cholesky matrix.

This will eventually be included into the Julia standard library. https://github.com/JuliaLang/julia/pull/53767

source
SpatiotemporalGPs.KalmanFilter.kalman_filterMethod
s_{k+1} = kalman_filter(s_k, y_{k+1}, u_k, A, B, C, V, W)

Runs both the prediction and the correction steps. Assumes a system model

\[ \begin{align} +Kalman Filters · SpatiotemporalGPs.jl

Kalman Filter

SpatiotemporalGPs.KalmanFilter.KFStateType
KFState{V, MU}

A type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.

source
SpatiotemporalGPs.KalmanFilter.KFStateMethod
KFState(; μ, Σ, make_symmetric=true)

A constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.

source
LinearAlgebra.choleskyMethod
M = cholesky(M::Cholesky)

This is a dummy method to allow for the cholesky method to be called on a cholesky decomposition.

source
SpatiotemporalGPs.KalmanFilter.diagMethod
diag(M::Cholesky)

is a fast method for getting the diagonal of a cholesky matrix.

This will eventually be included into the Julia standard library. https://github.com/JuliaLang/julia/pull/53767

source
SpatiotemporalGPs.KalmanFilter.filterMethod
s_{k+1} = filter(s_k, y_{k+1}, u_k, A, B, C, V, W)

Runs both the prediction and the correction steps. Assumes a system model

\[ \begin{align} x_{k+1} &= A x_k + B u_k + w, \\ y_k &= C x_k + v - \end{align}\]

where $w ∼ \mathcal{N}(0, W)$, $v ∼ \mathcal{N}(0, V)$.

source
+ \end{align}\]

where $w ∼ \mathcal{N}(0, W)$, $v ∼ \mathcal{N}(0, V)$.

source
diff --git a/dev/api/stgpkf/index.html b/dev/api/stgpkf/index.html index a087d5a..baf9ee8 100644 --- a/dev/api/stgpkf/index.html +++ b/dev/api/stgpkf/index.html @@ -1,2 +1,2 @@ -STGPKF · SpatiotemporalGPs.jl
+STGPKF · SpatiotemporalGPs.jl

STGPKP

SpatiotemporalGPs.STGPKF.STGPKFProblemMethod
STGPKFProblem(pts, ks, kt, ΔT)

Defines a spatiotemporal Gaussian Process Kalman Filter problem. Parameters are:

  • pts: grid points, a vector of all points. Ideally, eltype(pts) should be StaticVector for efficiency
  • ks: spatial kernel, must be of type AbstractKernel
  • kt: temporal kernel, must be of type AbstractKernel (but only AbstractMaternKernel is implemented)
  • ΔT: sampling period
source
SpatiotemporalGPs.STGPKF.MaternMethod
Matern(order, σ, l)

creates a Matern kernel with order order, variance σ, and lengthscale l. Order must be (1/2, 3/2, or 5/2). Returns a Matern12, Matern32, or Matern52 kernel.

source
SpatiotemporalGPs.STGPKF.get_estimateMethod
get_estimate(problem, state)

returns the estimate of the Kalman Filter for all grid points, in a Vector{F} format. The outer vector has same length as problem.pts.

source
SpatiotemporalGPs.STGPKF.get_estimate_percentileMethod
get_estimate_percentile(problem, state, percentile)

returns the percentile-% quantile of the estimated spatiotemporal field at all grid points, in a Vector{F} format. The vector has same length as problem.pts.

source
SpatiotemporalGPs.STGPKF.get_estimate_stdMethod
get_estimate_std(problem, state)

returns the standard deviation of the estimated spatiotemporal field at all grid points, in a Vector{F} format. The vector has same length as problem.pts.

source
SpatiotemporalGPs.STGPKF.get_statesMethod
get_states(problem, state)

returns the states of the Kalman Filter for all grid points, in a Vector{SVector{F}} format. The outer vector has same length as problem.pts.

source
SpatiotemporalGPs.STGPKF.kernel_matrixMethod
kernel_matrix(kernel, X, Y)

Compute the kernel matrix between two sets of points X and Y using the kernel function kernel. X must be a vector of points Y must be a vector of points

source
SpatiotemporalGPs.STGPKF.stgpkf_correctMethod
stgpkf_correct(prob, state, pt, y, σ_m)

corrects the state of the Kalman Filter given a single point measurement at $pt$ with value $y$ and measurement noise standard deviation $σ_m$.

source
SpatiotemporalGPs.STGPKF.stgpkf_correctMethod
stgpkf_correct(prob, state, pts, ys, Σm)

corrects the state of the Kalman Filter given multiple point measurements at $pts$ with values $ys$ and measurement noise covariance matrix $Σm$.

source
diff --git a/dev/index.html b/dev/index.html index e39ff7e..d581969 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · SpatiotemporalGPs.jl
+Home · SpatiotemporalGPs.jl
diff --git a/dev/kf/index.html b/dev/kf/index.html index 3523f03..0b31d92 100644 --- a/dev/kf/index.html +++ b/dev/kf/index.html @@ -1,19 +1,23 @@ -Kalman Filters · SpatiotemporalGPs.jl

Kalman Filtering

This module provides an efficient and computationally stable method of computing and propagating a Kalman Filter estimate.

The system model is

\[\begin{align} +Kalman Filters · SpatiotemporalGPs.jl

(Normal) Kalman Filtering

This module provides an efficient and computationally stable method of computing and propagating a Kalman Filter estimate. This module assumes a linear discrete time system. It can be a time-varying system.

The system model is

\[\begin{align*} x_{k+1} &= A x_k + B u_k + w,\\ y_k &= C x_k + v - \end{align}\]

where $w \sim \mathcal{N}(0, W)$, $v \sim \mathcal{N}(0, V)$.

Initializing

To initialize the KF,

s_0_0 = KFState(μ=μ, Σ=P) # estimated state at time k=0

which creates an KFState with mean $μ$ and covariance $P$. Pass in the full matrix here.

To get the mean, covariance, or marginal standard deviations

μ(s) # returns the mean
+  \end{align*}\]

where $w \sim \mathcal{N}(0, W)$, $v \sim \mathcal{N}(0, V)$.

Given $x_{k} \sim \mathcal{N}(\mu_{k|k}, P_{k|k})$, and the prediction step implements

\[ \begin{align*} + \mu_{k+1|k} &= A \mu_{k|k} + B u_k\\ + P_{k+1|k} &= A P_{k|k} A^T + W + \end{align*}\]

Then, given a measurement $y_{k+1}$, the correction step implements

\[\begin{align*} +\mu_{k+1|k+1} &= \mu_{k+1|k} + K ( y_{k+1} - C \mu_{k+1|k})\\ +P_{k+1|k+1} &= (I - K C) P_{k+1|k}\\ +K &= P_{k+1|k} C^T (C P_{k+1|k} C^T + V)^{-1} +\end{align*}\]

Initializing

To initialize the KF,

s_0_0 = KFState(μ=μ, Σ=P) # estimated state at time k=0

which creates an KFState with mean $μ$ and covariance $P$. Pass in the full matrix here.

To get the mean, covariance, or marginal standard deviations

μ(s) # returns the mean
 Σ(s) # returns the full covariance matrix
-σ(s) # returns the sqrt of the diagonal of the covariance matrix

Predicting and Correcting

Then, you can run a prediction step

u_0 = # control input at time k=0
+σ(s) # returns the sqrt of the diagonal of the covariance matrix

Predicting and Correcting

You can run a prediction step

u_0 = # control input at time k=0
 s_1_0 = predict(s_0_0, A, B, u_0, W)

now s_1_0 = $s_{1|0}$ is the kf state at time $k=1$ conditioned on measurements upto time $k=0$.

and then correct it use the measurement

y_1 = # measurement at time k=1
-s_1_1 = correct(s_1_0, y_1, C, V)

now s_1_1 = $s_{1|1}$ is the kf state at time $k=1$ conditioned on measurements upto time $k=1$.

You can also do the prediction and correction in the same step:

s_1_1 = kalman_filter(s_0_0, y_1, u_0, A, B, C, V, W)

Getters

To get the mean, covariance or standard deviations along the diagonal

  μ(s) # returns the mean
+s_1_1 = correct(s_1_0, y_1, C, V)

now s_1_1 = $s_{1|1}$ is the kf state at time $k=1$ conditioned on measurements upto time $k=1$.

You can also do the prediction and correction in the same step:

s_1_1 = kalman_filter(s_0_0, y_1, u_0, A, B, C, V, W)

Extracting State and Covariances

To get the mean, covariance or standard deviations along the diagonal

  μ(s) # returns the mean
   Σ(s) # returns the full covariance matrix
   σ(s) # returns the sqrt of the diagonal of the covariance matrix

These getters are useful since the s.F component of KFStruct is such that $Σ = FF^T$. By storing only the upper triangular part of the matrix, we have an efficient implementation that is also computationally stable.

References

This module basically implemented

@article{tracy2022square,
   title={A square-root kalman filter using only qr decompositions},
   author={Tracy, Kevin},
   journal={arXiv preprint arXiv:2208.06452},
   year={2022}
-}

Exported Symbols

SpatiotemporalGPs.KalmanFilter.KFStateMethod
KFState(; μ, Σ, make_symmetric=true)

A constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.

source
SpatiotemporalGPs.KalmanFilter.KFStateType
KFState{V, M}

A type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.

source
SpatiotemporalGPs.KalmanFilter.kalman_filterMethod
s_{k+1} = kalman_filter(s_k, y_{k+1}, u_k, A, B, C, V, W)

Runs both the prediction and the correction steps. Assumes a system model

\[ \begin{align} - x_{k+1} &= A x_k + B u_k + w, \\ - y_k &= C x_k + v - \end{align}\]

where $w ∼ \mathcal{N}(0, W)$, $v ∼ \mathcal{N}(0, V)$.

source
+}

Exported Symbols

SpatiotemporalGPs.KalmanFilter.KFStateMethod
KFState(; μ, Σ, make_symmetric=true)

A constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.

source
SpatiotemporalGPs.KalmanFilter.KFStateType
KFState{V, MU}

A type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.

source
diff --git a/dev/objects.inv b/dev/objects.inv index 0a7820e..0414c14 100644 Binary files a/dev/objects.inv and b/dev/objects.inv differ diff --git a/dev/search_index.js b/dev/search_index.js index ac67bde..87fd9be 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"api/kf/#Kalman-Filter","page":"Kalman Filters","title":"Kalman Filter","text":"","category":"section"},{"location":"api/kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Modules = [KalmanFilter] ","category":"page"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState{V, M}\n\nA type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.\n\n\n\n\n\n","category":"type"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.KFState-Tuple{}","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState(; μ, Σ, make_symmetric=true)\n\nA constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#LinearAlgebra.diag-Union{Tuple{LinearAlgebra.Cholesky{T}}, Tuple{T}} where T","page":"Kalman Filters","title":"LinearAlgebra.diag","text":"diag(M::Cholesky)\n\nis a fast method for getting the diagonal of a cholesky matrix.\n\nThis will eventually be included into the Julia standard library. https://github.com/JuliaLang/julia/pull/53767\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.chol_sqrt-Tuple{Any}","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.chol_sqrt","text":"U = chol_sqrt(A)\n\nreturns an upper-triangular matrix U such that A = U^T U.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.correct-Union{Tuple{S}, Tuple{S, Any, Any, Any}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.correct","text":"s_{k+1|k+1} = correct(s_{k+1|k}, y_{k+1}, C, V)\n\nUses the system model\n\ny_k+1 = C x_k+1 + v\n\nwhere v sim mathcalN(0 V) to correct the predicted state.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.kalman_filter-Union{Tuple{S}, Tuple{S, Vararg{Any, 7}}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.kalman_filter","text":"s_{k+1} = kalman_filter(s_k, y_{k+1}, u_k, A, B, C, V, W)\n\nRuns both the prediction and the correction steps. Assumes a system model\n\n beginalign\n x_k+1 = A x_k + B u_k + w \n y_k = C x_k + v\n endalign\n\nwhere w mathcalN(0 W), v mathcalN(0 V).\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Any, Any}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":"s_{k+1|k} = predict(s_{k|k}, A, W)\n\nUses the system model\n\n x_k+1 = A x_k + w\n\nwhere w N(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Vararg{Any, 4}}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":" s_{k+1} = predict(s_k, A, B, u_k, W)\n\nUses the system model\n\n x_k+1 = A x_k + B u_k + w\n\nwhere w mathcalN(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.qrr-Tuple{Any, Any}","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.qrr","text":"R = qrr(A, B)\n\nreturns \n\nR = sqrtA^TA + B^TB\n\nThe result is an UpperTriangular matrix.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.Σ-Tuple{S} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.Σ","text":"Σ(s::S) where {S <: KFState}\n\nGet the covariance matrix of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.μ-Tuple{S} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.μ","text":"μ(s::S) where {S <: KFState}\n\nGet the mean estimate of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.σ-Tuple{S} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.σ","text":"σ(s::S) where {S <: KFState}\n\nGet a vector of the standard deviation of the Kalman Filter State\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#STGPKP","page":"STGPKF","title":"STGPKP","text":"","category":"section"},{"location":"api/stgpkf/","page":"STGPKF","title":"STGPKF","text":"Modules = [STGPKF]","category":"page"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.Matern-Tuple{Any, Any, Any}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.Matern","text":"Matern(order, σ, l)\n\ncreates a Matern kernel with order order, variance σ, and lengthscale l. Order must be (1/2, 3/2, or 5/2).\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.kernel_matrix-Union{Tuple{KK}, Tuple{VP}, Tuple{P}, Tuple{KK, VP, VP}} where {P, VP<:AbstractVector{P}, KK<:SpatiotemporalGPs.STGPKF.AbstactKernel}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.kernel_matrix","text":"kernel_matrix(kernel, X, Y)\n\nCompute the kernel matrix between two sets of points X and Y using the kernel function kernel. X must be a vector of points Y must be a vector of points\n\n\n\n\n\n","category":"method"},{"location":"","page":"Home","title":"Home","text":"CurrentModule = SpatiotemporalGPs","category":"page"},{"location":"#SpatiotemporalGPs","page":"Home","title":"SpatiotemporalGPs","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Documentation for SpatiotemporalGPs.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Modules = [SpatiotemporalGPs]","category":"page"},{"location":"#SpatiotemporalGPs.greet-Tuple{Any}","page":"Home","title":"SpatiotemporalGPs.greet","text":"greet(n)\n\ngreeeeeeetings\n\n\n\n\n\n","category":"method"},{"location":"kf/#Kalman-Filtering","page":"Kalman Filters","title":"Kalman Filtering","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"This module provides an efficient and computationally stable method of computing and propagating a Kalman Filter estimate. ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"The system model is ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"beginalign\n x_k+1 = A x_k + B u_k + w\n y_k = C x_k + v\n endalign","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"where w sim mathcalN(0 W), v sim mathcalN(0 V).","category":"page"},{"location":"kf/#Initializing","page":"Kalman Filters","title":"Initializing","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"To initialize the KF, ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"s_0_0 = KFState(μ=μ, Σ=P) # estimated state at time k=0","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"which creates an KFState with mean μ and covariance P. Pass in the full matrix here.","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"To get the mean, covariance, or marginal standard deviations","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"μ(s) # returns the mean\nΣ(s) # returns the full covariance matrix\nσ(s) # returns the sqrt of the diagonal of the covariance matrix","category":"page"},{"location":"kf/#Predicting-and-Correcting","page":"Kalman Filters","title":"Predicting and Correcting","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Then, you can run a prediction step","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"u_0 = # control input at time k=0\ns_1_0 = predict(s_0_0, A, B, u_0, W)","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"now s_1_0 = s_10 is the kf state at time k=1 conditioned on measurements upto time k=0. ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"and then correct it use the measurement","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"y_1 = # measurement at time k=1\ns_1_1 = correct(s_1_0, y_1, C, V)","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"now s_1_1 = s_11 is the kf state at time k=1 conditioned on measurements upto time k=1. ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"You can also do the prediction and correction in the same step:","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"s_1_1 = kalman_filter(s_0_0, y_1, u_0, A, B, C, V, W)","category":"page"},{"location":"kf/#Getters","page":"Kalman Filters","title":"Getters","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"To get the mean, covariance or standard deviations along the diagonal","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":" μ(s) # returns the mean\n Σ(s) # returns the full covariance matrix\n σ(s) # returns the sqrt of the diagonal of the covariance matrix","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"These getters are useful since the s.F component of KFStruct is such that Σ = FF^T. By storing only the upper triangular part of the matrix, we have an efficient implementation that is also computationally stable. ","category":"page"},{"location":"kf/#References","page":"Kalman Filters","title":"References","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"This module basically implemented","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"@article{tracy2022square,\n title={A square-root kalman filter using only qr decompositions},\n author={Tracy, Kevin},\n journal={arXiv preprint arXiv:2208.06452},\n year={2022}\n}","category":"page"},{"location":"kf/#Exported-Symbols","page":"Kalman Filters","title":"Exported Symbols","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Modules = [KalmanFilter]\nPrivate = false","category":"page"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.KFState-Tuple{}-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState(; μ, Σ, make_symmetric=true)\n\nA constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState{V, M}\n\nA type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.\n\n\n\n\n\n","category":"type"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.correct-Union{Tuple{S}, Tuple{S, Any, Any, Any}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.correct","text":"s_{k+1|k+1} = correct(s_{k+1|k}, y_{k+1}, C, V)\n\nUses the system model\n\ny_k+1 = C x_k+1 + v\n\nwhere v sim mathcalN(0 V) to correct the predicted state.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.kalman_filter-Union{Tuple{S}, Tuple{S, Vararg{Any, 7}}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.kalman_filter","text":"s_{k+1} = kalman_filter(s_k, y_{k+1}, u_k, A, B, C, V, W)\n\nRuns both the prediction and the correction steps. Assumes a system model\n\n beginalign\n x_k+1 = A x_k + B u_k + w \n y_k = C x_k + v\n endalign\n\nwhere w mathcalN(0 W), v mathcalN(0 V).\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Any, Any}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":"s_{k+1|k} = predict(s_{k|k}, A, W)\n\nUses the system model\n\n x_k+1 = A x_k + w\n\nwhere w N(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Vararg{Any, 4}}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":" s_{k+1} = predict(s_k, A, B, u_k, W)\n\nUses the system model\n\n x_k+1 = A x_k + B u_k + w\n\nwhere w mathcalN(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.Σ-Tuple{S} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.Σ","text":"Σ(s::S) where {S <: KFState}\n\nGet the covariance matrix of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.μ-Tuple{S} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.μ","text":"μ(s::S) where {S <: KFState}\n\nGet the mean estimate of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.σ-Tuple{S} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.σ","text":"σ(s::S) where {S <: KFState}\n\nGet a vector of the standard deviation of the Kalman Filter State\n\n\n\n\n\n","category":"method"}] +[{"location":"stgpkf/#Spatiotemporal-Gaussian-Process-Kalman-Filtering","page":"STGPKF","title":"Spatiotemporal Gaussian Process Kalman Filtering","text":"","category":"section"},{"location":"stgpkf/#Theory","page":"STGPKF","title":"Theory","text":"","category":"section"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"STGPKF is a modelling technique to estimate the state of an environment.","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"In particular, the goal is to estimate a spatiotemporal field ","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"f mathcalR times mathcalD to mathcalR","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"i.e., f(t p) is the value of the field at time t and position p in mathcalD subset mathcalR^d. ","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"The assumption is that the field is a realization of a Gaussian Process:","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"f sim operatornameGP(m k)","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"with mean function m(t p) = 0 and kernel function ","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"k(t t p p) = k_t(t t) k_s(p p)","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"Notice, we explicitly assume the kernel is separable in space and time. ","category":"page"},{"location":"stgpkf/","page":"STGPKF","title":"STGPKF","text":"Modules = [STGPKF]\nPrivate = false","category":"page"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.STGPKFProblem-NTuple{4, Any}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.STGPKFProblem","text":"STGPKFProblem(pts, ks, kt, ΔT)\n\nDefines a spatiotemporal Gaussian Process Kalman Filter problem. Parameters are:\n\npts: grid points, a vector of all points. Ideally, eltype(pts) should be StaticVector for efficiency \nks: spatial kernel, must be of type AbstractKernel\nkt: temporal kernel, must be of type AbstractKernel (but only AbstractMaternKernel is implemented)\nΔT: sampling period\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.Matern-Tuple{Any, Any, Any}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.Matern","text":"Matern(order, σ, l)\n\ncreates a Matern kernel with order order, variance σ, and lengthscale l. Order must be (1/2, 3/2, or 5/2). Returns a Matern12, Matern32, or Matern52 kernel.\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.SquaredExponential-Tuple{Any, Any}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.SquaredExponential","text":"SquaredExponential(σ, l)\n\ncreates a Squared Exponential kernel with variance σ and lengthscale l. Returns a SqExp kernel.\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.kernel_matrix-Union{Tuple{KK}, Tuple{VPY}, Tuple{VPX}, Tuple{PY}, Tuple{PX}, Tuple{KK, VPX, VPY}} where {PX, PY, VPX<:AbstractVector{PX}, VPY<:AbstractVector{PY}, KK<:SpatiotemporalGPs.STGPKF.AbstractKernel}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.kernel_matrix","text":"kernel_matrix(kernel, X, Y)\n\nCompute the kernel matrix between two sets of points X and Y using the kernel function kernel. X must be a vector of points Y must be a vector of points\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_correct-Union{Tuple{F}, Tuple{P}, Tuple{STGPKFProblem{P, F, VP, KS, KT, DTSS, M1, M2} where {VP<:AbstractVector{P}, KS<:SpatiotemporalGPs.STGPKF.AbstractKernel, KT<:SpatiotemporalGPs.STGPKF.AbstractKernel, DTSS<:SpatiotemporalGPs.STGPKF.DiscreteTimeStateSpaceModel, M1<:AbstractMatrix{F}, M2<:AbstractMatrix{F}}, KFState, P, F, F}} where {P, F}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_correct","text":"stgpkf_correct(prob, state, pt, y, σ_m)\n\ncorrects the state of the Kalman Filter given a single point measurement at pt with value y and measurement noise standard deviation σ_m.\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_correct-Union{Tuple{MF}, Tuple{VF}, Tuple{VP}, Tuple{F}, Tuple{P}, Tuple{STGPKFProblem{P, F, VP, KS, KT, DTSS, M1, M2} where {VP<:AbstractVector{P}, KS<:SpatiotemporalGPs.STGPKF.AbstractKernel, KT<:SpatiotemporalGPs.STGPKF.AbstractKernel, DTSS<:SpatiotemporalGPs.STGPKF.DiscreteTimeStateSpaceModel, M1<:AbstractMatrix{F}, M2<:AbstractMatrix{F}}, KFState, VP, VF, MF}} where {P, F, VP<:AbstractVector{P}, VF<:AbstractVector{F}, MF<:AbstractMatrix{F}}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_correct","text":"stgpkf_correct(prob, state, pts, ys, Σm)\n\ncorrects the state of the Kalman Filter given multiple point measurements at pts with values ys and measurement noise covariance matrix Σm.\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_initialize-Tuple{STGPKFProblem}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_initialize","text":"stgpkf_initialize(problem)\n\nreturns a KFState that represents the initial state of the Kalman Filter for all grid points\n\n\n\n\n\n","category":"method"},{"location":"stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_predict-Tuple{STGPKFProblem, KFState}-stgpkf","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_predict","text":"stgpkf_predict(prob, state)\n\npredicts the next state of the Kalman Filter for all grid points\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#Kalman-Filter","page":"Kalman Filters","title":"Kalman Filter","text":"","category":"section"},{"location":"api/kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Modules = [KalmanFilter] ","category":"page"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState{V, MU}\n\nA type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.\n\n\n\n\n\n","category":"type"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.KFState-Tuple{}","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState(; μ, Σ, make_symmetric=true)\n\nA constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#LinearAlgebra.cholesky-Tuple{LinearAlgebra.Cholesky}","page":"Kalman Filters","title":"LinearAlgebra.cholesky","text":"M = cholesky(M::Cholesky)\n\nThis is a dummy method to allow for the cholesky method to be called on a cholesky decomposition.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.chol_sqrt-Tuple{Any}","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.chol_sqrt","text":"U = chol_sqrt(A)\n\nreturns an upper-triangular matrix U such that A = U^T U.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.correct-Union{Tuple{S}, Tuple{S, Any, Any, Any}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.correct","text":"s_{k+1|k+1} = correct(s_{k+1|k}, y_{k+1}, C, V)\n\nUses the system model\n\ny_k+1 = C x_k+1 + v\n\nwhere v sim mathcalN(0 V) to correct the predicted state.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.diag-Union{Tuple{LinearAlgebra.Cholesky{T}}, Tuple{T}, Tuple{LinearAlgebra.Cholesky{T}, Int64}} where T","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.diag","text":"diag(M::Cholesky)\n\nis a fast method for getting the diagonal of a cholesky matrix.\n\nThis will eventually be included into the Julia standard library. https://github.com/JuliaLang/julia/pull/53767\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.filter-Union{Tuple{S}, Tuple{S, Vararg{Any, 7}}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.filter","text":"s_{k+1} = filter(s_k, y_{k+1}, u_k, A, B, C, V, W)\n\nRuns both the prediction and the correction steps. Assumes a system model\n\n beginalign\n x_k+1 = A x_k + B u_k + w \n y_k = C x_k + v\n endalign\n\nwhere w mathcalN(0 W), v mathcalN(0 V).\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.get_Σ-Tuple{S} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.get_Σ","text":"get_Σ(s::S) where {S <: KFState}\n\nGet the covariance matrix of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.get_μ-Tuple{S} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.get_μ","text":"get_μ(s::S) where {S <: KFState}\n\nGet the mean estimate of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.get_σ-Tuple{S} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.get_σ","text":"get_σ(s::S) where {S <: KFState}\n\nGet a vector of the standard deviation of the Kalman Filter State\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Any, Any}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":"s_{k+1|k} = predict(s_{k|k}, A, W)\n\nUses the system model\n\n x_k+1 = A x_k + w\n\nwhere w N(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Vararg{Any, 4}}} where S<:KFState","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":" s_{k+1} = predict(s_k, A, B, u_k, W)\n\nUses the system model\n\n x_k+1 = A x_k + B u_k + w\n\nwhere w mathcalN(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"api/kf/#SpatiotemporalGPs.KalmanFilter.qrr-Tuple{Any, Any}","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.qrr","text":"R = qrr(A, B)\n\nreturns \n\nR = sqrtA^TA + B^TB\n\nThe result is an UpperTriangular matrix.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#STGPKP","page":"STGPKF","title":"STGPKP","text":"","category":"section"},{"location":"api/stgpkf/","page":"STGPKF","title":"STGPKF","text":"Modules = [STGPKF]","category":"page"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.STGPKFProblem-NTuple{4, Any}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.STGPKFProblem","text":"STGPKFProblem(pts, ks, kt, ΔT)\n\nDefines a spatiotemporal Gaussian Process Kalman Filter problem. Parameters are:\n\npts: grid points, a vector of all points. Ideally, eltype(pts) should be StaticVector for efficiency \nks: spatial kernel, must be of type AbstractKernel\nkt: temporal kernel, must be of type AbstractKernel (but only AbstractMaternKernel is implemented)\nΔT: sampling period\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.Matern-Tuple{Any, Any, Any}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.Matern","text":"Matern(order, σ, l)\n\ncreates a Matern kernel with order order, variance σ, and lengthscale l. Order must be (1/2, 3/2, or 5/2). Returns a Matern12, Matern32, or Matern52 kernel.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.SquaredExponential-Tuple{Any, Any}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.SquaredExponential","text":"SquaredExponential(σ, l)\n\ncreates a Squared Exponential kernel with variance σ and lengthscale l. Returns a SqExp kernel.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.checkdims-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.checkdims","text":"checkdims(prob, state)\n\nchecks that the dimensions of the state and the problem match\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_estimate-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_estimate","text":"get_estimate(problem, state)\n\nreturns the estimate of the Kalman Filter for all grid points, in a Vector{F} format. The outer vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_estimate_clarity-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_estimate_clarity","text":"get_estimate_clarities(problem, state)\n\nreturns the clarity of the estimated spatiotemporal field at all grid points, in a Vector{F} format. The vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_estimate_covariance-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_estimate_covariance","text":"get_estimate_covariance(problem, state)\n\nreturns the kalman filter's covariance of the estimated spatiotemporal field at all grid points, in a Vector{F} format. The vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_estimate_percentile-Tuple{STGPKFProblem, KFState, Any}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_estimate_percentile","text":"get_estimate_percentile(problem, state, percentile)\n\nreturns the percentile-% quantile of the estimated spatiotemporal field at all grid points, in a Vector{F} format. The vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_estimate_std-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_estimate_std","text":"get_estimate_std(problem, state)\n\nreturns the standard deviation of the estimated spatiotemporal field at all grid points, in a Vector{F} format. The vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_marginal_states-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_marginal_states","text":"get_marginal_states(problem, state)\n\nreturns the marginal states of the Kalman Filter for all grid points, in a Vector{KFState} format. The outer vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.get_states-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.get_states","text":"get_states(problem, state)\n\nreturns the states of the Kalman Filter for all grid points, in a Vector{SVector{F}} format. The outer vector has same length as problem.pts.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.kernel_matrix-Union{Tuple{KK}, Tuple{VPY}, Tuple{VPX}, Tuple{PY}, Tuple{PX}, Tuple{KK, VPX, VPY}} where {PX, PY, VPX<:AbstractVector{PX}, VPY<:AbstractVector{PY}, KK<:SpatiotemporalGPs.STGPKF.AbstractKernel}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.kernel_matrix","text":"kernel_matrix(kernel, X, Y)\n\nCompute the kernel matrix between two sets of points X and Y using the kernel function kernel. X must be a vector of points Y must be a vector of points\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.quantile-Tuple{Any, Any, Any}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.quantile","text":"quantile(μ, σ, q)\n\nFor a normal distribution with mean μ and standard deviation σ, this function returns the q-th quantile.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_correct-Union{Tuple{F}, Tuple{P}, Tuple{STGPKFProblem{P, F, VP, KS, KT, DTSS, M1, M2} where {VP<:AbstractVector{P}, KS<:SpatiotemporalGPs.STGPKF.AbstractKernel, KT<:SpatiotemporalGPs.STGPKF.AbstractKernel, DTSS<:SpatiotemporalGPs.STGPKF.DiscreteTimeStateSpaceModel, M1<:AbstractMatrix{F}, M2<:AbstractMatrix{F}}, KFState, P, F, F}} where {P, F}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_correct","text":"stgpkf_correct(prob, state, pt, y, σ_m)\n\ncorrects the state of the Kalman Filter given a single point measurement at pt with value y and measurement noise standard deviation σ_m.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_correct-Union{Tuple{MF}, Tuple{VF}, Tuple{VP}, Tuple{F}, Tuple{P}, Tuple{STGPKFProblem{P, F, VP, KS, KT, DTSS, M1, M2} where {VP<:AbstractVector{P}, KS<:SpatiotemporalGPs.STGPKF.AbstractKernel, KT<:SpatiotemporalGPs.STGPKF.AbstractKernel, DTSS<:SpatiotemporalGPs.STGPKF.DiscreteTimeStateSpaceModel, M1<:AbstractMatrix{F}, M2<:AbstractMatrix{F}}, KFState, VP, VF, MF}} where {P, F, VP<:AbstractVector{P}, VF<:AbstractVector{F}, MF<:AbstractMatrix{F}}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_correct","text":"stgpkf_correct(prob, state, pts, ys, Σm)\n\ncorrects the state of the Kalman Filter given multiple point measurements at pts with values ys and measurement noise covariance matrix Σm.\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_initialize-Tuple{STGPKFProblem}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_initialize","text":"stgpkf_initialize(problem)\n\nreturns a KFState that represents the initial state of the Kalman Filter for all grid points\n\n\n\n\n\n","category":"method"},{"location":"api/stgpkf/#SpatiotemporalGPs.STGPKF.stgpkf_predict-Tuple{STGPKFProblem, KFState}","page":"STGPKF","title":"SpatiotemporalGPs.STGPKF.stgpkf_predict","text":"stgpkf_predict(prob, state)\n\npredicts the next state of the Kalman Filter for all grid points\n\n\n\n\n\n","category":"method"},{"location":"","page":"Home","title":"Home","text":"CurrentModule = SpatiotemporalGPs","category":"page"},{"location":"#SpatiotemporalGPs","page":"Home","title":"SpatiotemporalGPs","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Documentation for SpatiotemporalGPs.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Modules = [SpatiotemporalGPs]","category":"page"},{"location":"kf/#(Normal)-Kalman-Filtering","page":"Kalman Filters","title":"(Normal) Kalman Filtering","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"This module provides an efficient and computationally stable method of computing and propagating a Kalman Filter estimate. This module assumes a linear discrete time system. It can be a time-varying system. ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"The system model is ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"beginalign*\n x_k+1 = A x_k + B u_k + w\n y_k = C x_k + v\n endalign*","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"where w sim mathcalN(0 W), v sim mathcalN(0 V).","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Given x_k sim mathcalN(mu_kk P_kk), and the prediction step implements ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":" beginalign*\n mu_k+1k = A mu_kk + B u_k\n P_k+1k = A P_kk A^T + W\n endalign*","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Then, given a measurement y_k+1, the correction step implements","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"beginalign*\nmu_k+1k+1 = mu_k+1k + K ( y_k+1 - C mu_k+1k)\nP_k+1k+1 = (I - K C) P_k+1k\nK = P_k+1k C^T (C P_k+1k C^T + V)^-1\nendalign*","category":"page"},{"location":"kf/#Initializing","page":"Kalman Filters","title":"Initializing","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"To initialize the KF, ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"s_0_0 = KFState(μ=μ, Σ=P) # estimated state at time k=0","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"which creates an KFState with mean μ and covariance P. Pass in the full matrix here.","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"To get the mean, covariance, or marginal standard deviations","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"μ(s) # returns the mean\nΣ(s) # returns the full covariance matrix\nσ(s) # returns the sqrt of the diagonal of the covariance matrix","category":"page"},{"location":"kf/#Predicting-and-Correcting","page":"Kalman Filters","title":"Predicting and Correcting","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"You can run a prediction step","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"u_0 = # control input at time k=0\ns_1_0 = predict(s_0_0, A, B, u_0, W)","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"now s_1_0 = s_10 is the kf state at time k=1 conditioned on measurements upto time k=0. ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"and then correct it use the measurement","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"y_1 = # measurement at time k=1\ns_1_1 = correct(s_1_0, y_1, C, V)","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"now s_1_1 = s_11 is the kf state at time k=1 conditioned on measurements upto time k=1. ","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"You can also do the prediction and correction in the same step:","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"s_1_1 = kalman_filter(s_0_0, y_1, u_0, A, B, C, V, W)","category":"page"},{"location":"kf/#Extracting-State-and-Covariances","page":"Kalman Filters","title":"Extracting State and Covariances","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"To get the mean, covariance or standard deviations along the diagonal","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":" μ(s) # returns the mean\n Σ(s) # returns the full covariance matrix\n σ(s) # returns the sqrt of the diagonal of the covariance matrix","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"These getters are useful since the s.F component of KFStruct is such that Σ = FF^T. By storing only the upper triangular part of the matrix, we have an efficient implementation that is also computationally stable. ","category":"page"},{"location":"kf/#References","page":"Kalman Filters","title":"References","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"This module basically implemented","category":"page"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"@article{tracy2022square,\n title={A square-root kalman filter using only qr decompositions},\n author={Tracy, Kevin},\n journal={arXiv preprint arXiv:2208.06452},\n year={2022}\n}","category":"page"},{"location":"kf/#Exported-Symbols","page":"Kalman Filters","title":"Exported Symbols","text":"","category":"section"},{"location":"kf/","page":"Kalman Filters","title":"Kalman Filters","text":"Modules = [KalmanFilter]\nPrivate = false","category":"page"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.KFState-Tuple{}-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState(; μ, Σ, make_symmetric=true)\n\nA constructor for the Kalman Filter State, which is parameterized by the mean estimate and the covariance matrix. If make_symmetric is true, the covariance matrix is made symmetric internally. This is useful for numerical stability.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.KFState","text":"KFState{V, MU}\n\nA type for the Kalman Filter State, which is parameterized by the types of the mean estimate and the upper triangular cholesky component of the covariance matrix.\n\n\n\n\n\n","category":"type"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.correct-Union{Tuple{S}, Tuple{S, Any, Any, Any}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.correct","text":"s_{k+1|k+1} = correct(s_{k+1|k}, y_{k+1}, C, V)\n\nUses the system model\n\ny_k+1 = C x_k+1 + v\n\nwhere v sim mathcalN(0 V) to correct the predicted state.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.get_Σ-Tuple{S} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.get_Σ","text":"get_Σ(s::S) where {S <: KFState}\n\nGet the covariance matrix of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.get_μ-Tuple{S} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.get_μ","text":"get_μ(s::S) where {S <: KFState}\n\nGet the mean estimate of the Kalman Filter State.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.get_σ-Tuple{S} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.get_σ","text":"get_σ(s::S) where {S <: KFState}\n\nGet a vector of the standard deviation of the Kalman Filter State\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Any, Any}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":"s_{k+1|k} = predict(s_{k|k}, A, W)\n\nUses the system model\n\n x_k+1 = A x_k + w\n\nwhere w N(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"},{"location":"kf/#SpatiotemporalGPs.KalmanFilter.predict-Union{Tuple{S}, Tuple{S, Vararg{Any, 4}}} where S<:KFState-kf","page":"Kalman Filters","title":"SpatiotemporalGPs.KalmanFilter.predict","text":" s_{k+1} = predict(s_k, A, B, u_k, W)\n\nUses the system model\n\n x_k+1 = A x_k + B u_k + w\n\nwhere w mathcalN(0 W) to predict the next state.\n\n\n\n\n\n","category":"method"}] } diff --git a/dev/stgpkf/index.html b/dev/stgpkf/index.html new file mode 100644 index 0000000..f72e1f4 --- /dev/null +++ b/dev/stgpkf/index.html @@ -0,0 +1,2 @@ + +STGPKF · SpatiotemporalGPs.jl

Spatiotemporal Gaussian Process Kalman Filtering

Theory

STGPKF is a modelling technique to estimate the state of an environment.

In particular, the goal is to estimate a spatiotemporal field

\[f : \mathcal{R} \times \mathcal{D} \to \mathcal{R}\]

i.e., $f(t, p)$ is the value of the field at time $t$ and position $p \in \mathcal{D} \subset \mathcal{R}^d$.

The assumption is that the field is a realization of a Gaussian Process:

\[f \sim \operatorname{GP}(m, k)\]

with mean function $m(t, p) = 0$ and kernel function

\[k(t, t', p, p') = k_t(t, t') k_s(p, p')\]

Notice, we explicitly assume the kernel is separable in space and time.

SpatiotemporalGPs.STGPKF.STGPKFProblemMethod
STGPKFProblem(pts, ks, kt, ΔT)

Defines a spatiotemporal Gaussian Process Kalman Filter problem. Parameters are:

  • pts: grid points, a vector of all points. Ideally, eltype(pts) should be StaticVector for efficiency
  • ks: spatial kernel, must be of type AbstractKernel
  • kt: temporal kernel, must be of type AbstractKernel (but only AbstractMaternKernel is implemented)
  • ΔT: sampling period
source
SpatiotemporalGPs.STGPKF.MaternMethod
Matern(order, σ, l)

creates a Matern kernel with order order, variance σ, and lengthscale l. Order must be (1/2, 3/2, or 5/2). Returns a Matern12, Matern32, or Matern52 kernel.

source
SpatiotemporalGPs.STGPKF.kernel_matrixMethod
kernel_matrix(kernel, X, Y)

Compute the kernel matrix between two sets of points X and Y using the kernel function kernel. X must be a vector of points Y must be a vector of points

source
SpatiotemporalGPs.STGPKF.stgpkf_correctMethod
stgpkf_correct(prob, state, pt, y, σ_m)

corrects the state of the Kalman Filter given a single point measurement at $pt$ with value $y$ and measurement noise standard deviation $σ_m$.

source
SpatiotemporalGPs.STGPKF.stgpkf_correctMethod
stgpkf_correct(prob, state, pts, ys, Σm)

corrects the state of the Kalman Filter given multiple point measurements at $pts$ with values $ys$ and measurement noise covariance matrix $Σm$.

source