Class prob_dens_mdim_biv_gaussian (o2scl)

O2scl : Class List

template<class vec_t = boost::numeric::ublas::vector<double>>
class o2scl::prob_dens_mdim_biv_gaussian : public o2scl::prob_dens_mdim<boost::numeric::ublas::vector<double>>

A bivariate gaussian probability distribution.

For a two-dimensional gaussian, given a mean \( ( \mu_x, \mu_y ) \) and a covariance matrix

\[\begin{split} \Sigma = \left( \begin{array}{cc} \sigma_x^2 & \rho \sigma_x \sigma_y \\ \rho \sigma_x \sigma_y & \sigma_y^2 \\ \end{array} \right) \end{split}\]
the PDF is
\[ pdf(x,y) = \left(2 \pi \sigma_x \sigma_y \sqrt{1-\rho^2}\right)^{-1} \exp \left\{ - \frac{1}{2 (1-\rho^2)} \left[ \frac{(x-\mu_x)^2}{\sigma_x^2} + \frac{(y-\mu_y)^2}{\sigma_y^2} - \frac{2 \rho (x-\mu_x)(y-\mu_y)}{\sigma_x \sigma_y} \right] \right\} \]

(taken from the Wikipedia page on the “Multivariate normal

distribution”).

The function o2scl::prob_dens_mdim_biv_gaussian::contour() gives a point on the contour line for a fixed value of the PDF given an angle \( \theta \). In particular, it solves

\[ c = pdf(r \cos \theta + \mu_x, r \sin \theta + \mu_y ) \]
for the radius \( r \) and then stores the values \( r \cos \theta + \mu_x \) and \( r \sin \theta + \mu_y \) in the reference parameters named x and y . Thus this function can be used to map out the full contour by selecting values for \( \theta \in [0,2 \pi] \).

The function o2scl::prob_dens_mdim_biv_gaussian::level_fixed_integral() gives the value of the PDF for which the integral inside the corresponding contour is some fraction of the total integral (which is always 1). Given a fraction \( f \), the argument of the exponential is related to the inverse of the cumulative distribution function for the chi-squared probability distribution for two degrees of freedom for \( 1-f \). For a fraction \( f \), the value \( \chi^2 \) (i.e. the Mahalanobis distance) is \( \chi^2 = -2 \log (1-f) \) and then the value of the PDF for the corresponding contour is \( pdf(x,y) = \left(2 \pi \sigma_x \sigma_y \sqrt{1-\rho^2}\right)^{-1} \exp (-\chi^2/2) \) .

Public Functions

inline prob_dens_mdim_biv_gaussian()
inline prob_dens_mdim_biv_gaussian(const prob_dens_mdim_biv_gaussian &pdmbg)

Copy constructor.

inline prob_dens_mdim_biv_gaussian &operator=(const prob_dens_mdim_biv_gaussian &pdmbg)

Copy constructor with operator=.

inline void set(double x_cent, double y_cent, double x_std, double y_std, double covar)

Set the properties of the distribution.

Note

If \( |\rho|\geq 1 \) this function will call the error handler.

inline virtual double pdf(const vec_t &v) const

Compute the normalized probability density.

inline virtual double level_fixed_integral(double integral)

Return the contour level corresponding to a fixed integral.

inline virtual void contour(double level, double theta, vec_t &x)

Return a point on the contour for a specified level given an angle.

Private Members

double x0

The x coordinate of the centroid.

double y0

The y coordinate of the centroid.

double sig_x

The x standard deviation.

double sig_y

The y standard deviation.

double rho

The covariance.