diff --git a/doc/multivariate_normal_distribution.html b/doc/multivariate_normal_distribution.html
index 8539405..68d7fa3 100644
--- a/doc/multivariate_normal_distribution.html
+++ b/doc/multivariate_normal_distribution.html
@@ -34,8 +34,7 @@ public:
typedef numeric::ublas::vector<RealType> vector_type;
typedef numeric::ublas::matrix<RealType> matrix_type;
- explicit multivariate_normal_distribution(const vector_type& m,
- const matrix_type& c);
+ multivariate_normal_distribution(const vector_type& m, const matrix_type& c);
explicit multivariate_normal_distribution(const matrix_type& c)
@@ -68,8 +67,7 @@ variance and then calculates the multivariate randim numbers using the equation
Members
- explicit multivariate_normal_distribution(const vector_type& m,
- const matrix_type& c);
+ multivariate_normal_distribution(const vector_type& m, const matrix_type& c);
Requires: m.size() == c.size1() && c.size1() == c.size2()
@@ -108,8 +106,60 @@ of multivariate normally distributed random numbers.
Effects: Clears the cache of multivariate normally distributed random numbers.
The next call to operator()(UniformRandomNumberGenerator& urng) will create a new vector
of multivariate normally distributed random numbers.
-
+
Example
+
+In the example we print 100 pairs of correlated Gaussian random numbers, with mean
+
+
+
+and covariance matrix
+
+
+
+The Cholesky decomposition (square root) of the covariance matrix in this case is
+
+
+
+
+
+#include <boost/random/multivariate_normal_distribution.hpp>
+#include <boost/random.hpp>
+#include <iostream>
+
+int main()
+{
+
+ // Create multivariate correlated Gaussians with mean (-1, 1) and covariance
+ // matrix ((2,2),(2,2))
+
+ typedef boost::multivariate_normal_distribution<double> distribution_type;
+
+ // the square root (Cholesky decomposition) of the covariance matrix
+ distribution_type::matrix_type cholesky(2,2);
+ cholesky(0,0)=1.;
+ cholesky(0,1)=1.;
+ cholesky(1,0)=1.;
+ cholesky(1,1)=1.;
+
+ // the vector of mean values
+ distribution_type::vector_type mean(2);
+ mean(0)=-1.;
+ mean(1)=1.;
+
+ // create the engine, distribution, and variate generator
+ boost::mt19937 engine;
+ distribution_type dist(cholesky,mean);
+ boost::variate_generator<boost::mt19937,distribution_type>
+ gen(engine,dist);
+
+ // print 100 pairs of correlated normally distributed random numbers
+ for (int i=0; i<100; ++i)
+ std::cout << gen() << " " << gen() << "\n";
+}
+
+
+
Matthias Troyer, 2006-02-06