Public Member Functions | Private Attributes | List of all members
o2scl::prob_dens_mdim_biv_gaussian< vec_t > Class Template Reference

A bivariate gaussian probability distribution. More...

#include <prob_dens_func.h>

Inheritance diagram for o2scl::prob_dens_mdim_biv_gaussian< vec_t >:
o2scl::prob_dens_mdim< vec_t >

Detailed Description

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

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

\[ \Sigma = \left( \begin{array}{cc} \sigma_x^2 & \rho \sigma_x \sigma_y \\ \rho \sigma_x \sigma_y & \sigma_y^2 \\ \end{array} \right) \]

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) $ .

Definition at line 836 of file prob_dens_func.h.

Public Member Functions

 prob_dens_mdim_biv_gaussian (const prob_dens_mdim_biv_gaussian &pdmbg)
 Copy constructor.
 
prob_dens_mdim_biv_gaussianoperator= (const prob_dens_mdim_biv_gaussian &pdmbg)
 Copy constructor with operator=.
 
void set (double x_cent, double y_cent, double x_std, double y_std, double covar)
 Set the properties of the distribution. More...
 
virtual double pdf (const vec_t &v) const
 Compute the normalized probability density.
 
virtual double level_fixed_integral (double integral)
 Return the contour level corresponding to a fixed integral.
 
virtual void contour (double level, double theta, vec_t &x)
 Return a point on the contour for a specified level given an angle.
 
- Public Member Functions inherited from o2scl::prob_dens_mdim< vec_t >
virtual size_t dim () const
 Return the dimensionality.
 
virtual double log_pdf (const vec_t &x) const
 The log of the normalized density.
 
virtual void operator() (vec_t &x) const
 Sample the distribution.
 

Private Attributes

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.
 

Member Function Documentation

◆ set()

template<class vec_t = boost::numeric::ublas::vector<double>>
void o2scl::prob_dens_mdim_biv_gaussian< vec_t >::set ( double  x_cent,
double  y_cent,
double  x_std,
double  y_std,
double  covar 
)
inline
Note
If $ |\rho|\geq 1 $ this function will call the error handler.

Definition at line 888 of file prob_dens_func.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).