Gaussian

class kalman.gaussian.GaussianState(mean: torch.Tensor, covariance: torch.Tensor, precision: torch.Tensor | None = None)[source]

Class for Gaussian state.

Attributes:
mean (torch.Tensor): Mean of the distribution

Shape: (*, dim, 1)

covariance (torch.Tensor): Covariance of the distribution

Shape: (*, dim, dim)

precision (Optional[torch.Tensor]): Optional inverse covariance matrix

This may be useful for some computations (E.G mahalanobis distance, likelihood) after a predict step. Shape: (*, dim, dim)

clone() GaussianState[source]

Clone the Gaussian State using torch.Tensor.clone

Returns:

GaussianState: A copy of the Gaussian state

likelihood(measure: torch.Tensor) torch.Tensor[source]

Computes the likelihood of given measure

It supports batch computation: You can provide multiple measurements and have multiple states You just need to ensure that shapes are broadcastable.

Args:
measure (torch.Tensor): Points to consider

Shape: (*, dim, 1)

Returns:
torch.Tensor: Likelihood for each measure/state

Shape: (*, 1)

log_likelihood(measure: torch.Tensor) torch.Tensor[source]

Computes the log-likelihood of given measure

It supports batch computation: You can provide multiple measurements and have multiple states You just need to ensure that shapes are broadcastable.

Args:
measure (torch.Tensor): Points to consider

Shape: (*, dim, 1)

Returns:
torch.Tensor: Log-likelihood for each measure/state

Shape: (*, 1)

mahalanobis(measure: torch.Tensor) torch.Tensor[source]

Computes the mahalanobis distance of given measure

Computations of the sqrt can be slow. If you want to compare with a given threshold, you should rather compare the squared mahalanobis with the squared threshold.

It supports batch computation: You can provide multiple measurements and have multiple states You just need to ensure that shapes are broadcastable.

Args:
measure (torch.Tensor): Points to consider

Shape: (*, dim, 1)

Returns:
torch.Tensor: Mahalanobis distance for each measure/state

Shape: (*)

mahalanobis_squared(measure: torch.Tensor) torch.Tensor[source]

Computes the squared mahalanobis distance of given measure

It supports batch computation: You can provide multiple measurements and have multiple states You just need to ensure that shapes are broadcastable.

Args:
measure (torch.Tensor): Points to consider

Shape: (*, dim, 1)

Returns:
torch.Tensor: Squared mahalanobis distance for each measure/state

Shape: (*)

to(dtype: torch.dtype) GaussianState[source]
to(device: torch.device) GaussianState

Convert a GaussianState to a specific device or dtype

Args:

fmt (torch.dtype | torch.device): Memory format to send the state to.

Returns:

GaussianState: The GaussianState with the right format