
Firstly, Boost.uBLAS has limited serialization support in its CVS snapshot at time of writing (3 Sep 2007). It appears limited to the serialization of basic vectors and matrices: symmetric matrices do not appear to be supported, for example.
Secondly, it's arguable whether serializing pre-calculations is useful or not. It makes for larger messages in a parallel environment, the cost of sending which may exceed the savings of the precalculations in the first place.
The implementation here takes the path of least resistance in both cases. We choose to use the limited Boost.uBLAS serialization features anyway for ease of implementation, presuming that eventually full serialization support will be provided. We also choose to serialize just the bare essentials, excluding pre-calculation results.
Definition at line 40 of file GaussianPdf.hpp.
Public Member Functions | |
| GaussianPdf () | |
| Default constructor. | |
| GaussianPdf (const vector &mu, const symmetric_matrix &sigma) | |
| Construct Gaussian given mean and covariance. | |
| GaussianPdf (unsigned int N) | |
| Construct Gaussian given dimensionality. | |
| GaussianPdf & | operator= (const GaussianPdf &o) |
| Assignment operator. | |
| virtual | ~GaussianPdf () |
| Destructor. | |
| virtual void | setDimensions (const unsigned int N, const bool preserve=false) |
| Set the dimensionality of the distribution. | |
| virtual const vector & | getExpectation () const |
| Get the expected value of the distribution. | |
| virtual const symmetric_matrix & | getCovariance () const |
| Get the covariance of the distribution. | |
| virtual const vector & | getExpectation () |
| Get the expected value of the distribution. | |
| virtual const symmetric_matrix & | getCovariance () |
| Get the covariance of the distribution. | |
| virtual void | setExpectation (const vector &mu) |
| Set the mean of the Gaussian. | |
| virtual void | setCovariance (const symmetric_matrix &sigma) |
| Set the covariance of the Gaussian. | |
| virtual vector | sample () |
| Sample from the Gaussian. | |
| double | calculateDensity (const vector &x) |
| virtual double | densityAt (const vector &x) |
| Calculate the density at a given point. | |
Protected Member Functions | |
| virtual void | dirty () |
| Called when changes are made to the distribution, such as when the expectation or covariance is changed. | |
| GaussianPdf | ( | ) |
Default constructor.
Initialises the Gaussian with zero dimensions. This should generally only be used when the object is to be restored from a serialization.
Definition at line 20 of file GaussianPdf.cpp.
| GaussianPdf | ( | const vector & | mu, | |
| const symmetric_matrix & | sigma | |||
| ) |
Construct Gaussian given mean and covariance.
| mu | ; mean of the Gaussian. | |
| sigma | ; covariance of the Gaussian. |
Definition at line 26 of file GaussianPdf.cpp.
| GaussianPdf | ( | unsigned int | N | ) |
Construct Gaussian given dimensionality.
The mean and covariance remain uninitialised, and should be set with setExpectation() and setCovariance().
| N | ; number of dimensions of the Gaussian. |
Definition at line 40 of file GaussianPdf.cpp.
| ~GaussianPdf | ( | ) | [virtual] |
| GaussianPdf & operator= | ( | const GaussianPdf & | o | ) |
Assignment operator.
Both sides must have the same dimensionality.
Definition at line 46 of file GaussianPdf.cpp.
| void setDimensions | ( | const unsigned int | N, | |
| const bool | preserve = false | |||
| ) | [virtual] |
Set the dimensionality of the distribution.
| N | Dimensionality of the distribution. | |
| preserve | True to preserve the current sufficient statistics of the distribution in the lower dimensional space, false if these may be discarded. |
Implements Pdf.
Definition at line 85 of file GaussianPdf.cpp.
| const vector & getExpectation | ( | ) | const [virtual] |
Get the expected value of the distribution.
; expected value of the distribution. Definition at line 97 of file GaussianPdf.cpp.
| const symmetric_matrix & getCovariance | ( | ) | const [virtual] |
Get the covariance of the distribution.
; covariance of the distribution. Definition at line 101 of file GaussianPdf.cpp.
| const vector & getExpectation | ( | ) | [virtual] |
Get the expected value of the distribution.
; expected value of the distribution. Implements Pdf.
Definition at line 105 of file GaussianPdf.cpp.
| const symmetric_matrix & getCovariance | ( | ) | [virtual] |
Get the covariance of the distribution.
; covariance of the distribution. Implements Pdf.
Definition at line 109 of file GaussianPdf.cpp.
| void setExpectation | ( | const vector & | mu | ) | [virtual] |
Set the mean of the Gaussian.
The new mean vector must have the same size as the previous one.
| mu | ; mean of the Gaussian. |
Definition at line 113 of file GaussianPdf.cpp.
| void setCovariance | ( | const symmetric_matrix & | sigma | ) | [virtual] |
Set the covariance of the Gaussian.
The new covariance matrix must have the same size as the previous one.
| sigma | ; covariance of the Gaussian. |
Definition at line 121 of file GaussianPdf.cpp.
| vector sample | ( | ) | [virtual] |
Sample from the Gaussian.
be a vector of
independent normal variates.
, where
is the Cholesky decomposition of the covariance matrix
.
Implements Pdf.
Definition at line 129 of file GaussianPdf.cpp.
| double calculateDensity | ( | const vector & | x | ) |
| double densityAt | ( | const vector & | x | ) | [virtual] |
Calculate the density at a given point.
| x | ; point at which to evaluate the density. |
; the density at
. Implements Pdf.
Definition at line 147 of file GaussianPdf.cpp.
| void dirty | ( | ) | [protected, virtual] |
Called when changes are made to the distribution, such as when the expectation or covariance is changed.
This allows pre-calculations to be refreshed.
Definition at line 180 of file GaussianPdf.cpp.
1.5.3