2 #ifndef vpdl_gaussian_sphere_h_ 3 #define vpdl_gaussian_sphere_h_ 19 # include <vcl_msvc_warnings.h> 28 template<
class T,
unsigned int n=0>
47 :
impl_(mean_val,var) {}
64 return impl_.density(pt);
85 return impl_.gradient_density(pt,g);
93 return impl_.norm_const();
100 return impl_.sqr_mahal_dist(pt);
108 return impl_.cumulative_prob(pt);
116 const unsigned int dim = this->
dimension();
118 double s2 = 1/std::sqrt(2*
impl_.covar);
121 for (
unsigned int i=0; i<dim; ++i) {
127 return static_cast<T>(prob);
149 impl_.compute_covar(covar);
158 #endif // vpdl_gaussian_sphere_h_ vpdt_field_traits< field_type >::matrix_type matrix
the data type used for matrices.
virtual T density(const vector &pt) const
Evaluate the unnormalized density at a point.
virtual void set_mean(const vector &mean_val)
Set the mean.
T sqr_mahal_dist(const vector &pt) const
The squared Mahalanobis distance to this point.
vpdt_field_traits< vector >::matrix_type matrix
the data type used for matrices.
The basic functions for probability calculations.
virtual void compute_covar(matrix &covar) const
Compute the covariance of the distribution.
T covar_type
the type used internally for covariance.
virtual void compute_mean(vector &mean_val) const
Compute the mean of the distribution.
T & vpdt_index(vnl_vector< T > &v, unsigned int i)
Index into a vnl_vector.
The abstract base class for Gaussian distributions.
A Gaussian with (hyper-)spherical covariance.
vpdl_gaussian_sphere(unsigned int var_dim=n)
Constructor.
vpdt_gaussian< vector, covar_type > impl_
the Gaussian implementation from vpdt.
vpdt_field_default< T, n >::type vector
the data type used for vectors.
T vpdt_log_prob_density(const vpdl_distribution< T, n > &d, const typename vpdt_field_default< T, n >::type &pt)
The log probability density wrapper for vpdt.
virtual unsigned int dimension() const
Return the run time dimension, which does not equal n when n==0.
T box_prob(const vector &min_pt, const vector &max_pt) const
The probability of being in an axis-aligned box.
virtual T cumulative_prob(const vector &pt) const
Evaluate the cumulative distribution function at a point.
A Gaussian with variance independent in each dimension.
vpdl_gaussian_sphere(const vector &mean_val, const covar_type &var)
Constructor - from mean and variance.
T norm_const() const
The normalization constant for the density.
The abstract base class for Gaussian distributions.
A generic Gaussian distribution.
T vpdt_prob_density(const vpdl_distribution< T, n > &d, const typename vpdt_field_default< T, n >::type &pt)
probability density wrapper for vpdt.
virtual T log_prob_density(const vector &pt) const
Evaluate the log probability density at a point.
The field traits class (scalar).
virtual const vector & mean() const
Access the mean directly.
The base class for all probability distributions.
void set_covariance(const covar_type &var)
Set the scalar variance.
virtual T prob_density(const vector &pt) const
Evaluate the probability density at a point.
The basic functions for log of probability calculation.
virtual T gradient_density(const vector &pt, vector &g) const
Compute the gradient of the unnormalized density at a point.
const covar_type & covariance() const
Access the scalar variance.
virtual vpdl_distribution< T, n > * clone() const
Create a copy on the heap and return base class pointer.
virtual ~vpdl_gaussian_sphere()
Destructor.