Covariance Utilities 
Top Previous Next 
The builtin CovarianceUtilities object provides several static utility methods for working with a covariance matrix. It provides the capability to:
The CovarianceUtilities object assumes that the random states are normally distributed.
Generating Random States Based on a CovarianceThe CovarianceUtilities.GetRandomState() and CovarianceUtilities.GetRandomStates() methods can be used to generate one or more random states based on an input mean state and covariance matrix. When using these methods, the mean state must have the same number of elements as the length of the diagonal of the covariance matrix.
These methods can be used as shown in the example script below.
The random states can then be displayed in a ViewWindow using a Formation object or propagated alongside the mean state if desired.
Random states generated using a Spacecraft covariance
Computing the Mean State and Covariance from a Distribution of StatesThe CovarianceUtilities.CalculateCovariance() and CovarianceUtilities.CalculateMeanAndCovariance() methods can be used to compute the covariance matrix and mean state from a set of normally distributed random states. All random state vectors must have the same number of elements, and number of elements will determine the dimension of the resulting mean state and covariance matrix.
These methods can be used as shown in the example below.
Computing the Mahalanobis Distance Using a Mean State and CovarianceThe Mahalanobis distance is a nondimensional measure of the distance between a state and a distribution. It takes into account the correlations of the distribution and is a representation of how many standard deviations the state is away from the mean of the distribution. The CovarianceUtilities.CalculateMahalanobisDistance() method can be used to compute the Mahalanobis distance for a state vector using a mean state and covariance matrix as in the example below.
(1) Mahalanobis, Prasanta Chandra (1936). "On the Generalised Distance in Statistics". Proceedings of the National Institute of Sciences of India, p. 4955.
See Also
