2 #ifndef vpdl_kernel_gaussian_sfbw_h_ 3 #define vpdl_kernel_gaussian_sfbw_h_ 21 # include <vcl_msvc_warnings.h> 27 template<
class T,
unsigned int n=0>
59 typedef typename std::vector<vector>::const_iterator vitr;
60 for (vitr s=this->
samples().begin(); s!=this->
samples().end(); ++s) {
62 for (
unsigned int i=0; i<d; ++i) {
66 sum += T(std::exp(-0.5*ssd));
98 typedef typename std::vector<vector>::const_iterator vitr;
99 for (vitr s=this->
samples().begin(); s!=this->
samples().end(); ++s) {
101 for (
unsigned int i=0; i<d; ++i) {
106 T dens = T(std::exp(-0.5*ssd));
124 const unsigned int d = this->
dimension();
125 double s2 = 1/(this->
bandwidth()*std::sqrt(2.0));
128 typedef typename std::vector<vector>::const_iterator vitr;
129 for (vitr s=this->
samples().begin(); s!=this->
samples().end(); ++s) {
131 for (
unsigned int i=0; i<d; ++i) {
136 return static_cast<T>(sum/nc);
148 const unsigned int dim = this->
dimension();
149 double s2 = 1/(this->
bandwidth()*std::sqrt(2.0));
152 typedef typename std::vector<vector>::const_iterator vitr;
153 for (vitr s=this->
samples().begin(); s!=this->
samples().end(); ++s) {
155 for (
unsigned int i=0; i<dim; ++i) {
163 return static_cast<T>(sum/nc);
169 const unsigned int d = this->
dimension();
176 typedef typename std::vector<vector>::const_iterator samp_itr;
177 for (samp_itr s = this->
samples().begin(); s != this->
samples().end(); ++s) {
185 for (
unsigned int i=0; i<d; ++i)
192 const unsigned int dim = this->
dimension();
195 for (
unsigned int i=1; i<dim; ++i)
198 return static_cast<T>(std::sqrt(1/denom));
203 #endif // vpdl_kernel_gaussian_sfbw_h_ vpdt_field_traits< field_type >::matrix_type matrix
the data type used for matrices.
virtual unsigned int dimension() const
Return the run time dimension, which does not equal n when n==0.
virtual T cumulative_prob(const vector &pt) const
Evaluate the cumulative distribution function at a point.
T bandwidth() const
Access the bandwidth.
virtual T prob_density(const vector &pt) const
Evaluate the probability density at a point.
virtual T density(const vector &pt) const
Evaluate the unnormalized density at a point.
vpdt_field_traits< vector >::matrix_type matrix
the data type used for matrices.
vpdl_kernel_gaussian_sfbw()
Default Constructor.
virtual T kernel_norm_const() const
The normalization constant for the kernel.
virtual vpdl_distribution< T, n > * clone() const
Create a copy on the heap and return base class pointer.
virtual T gradient_density(const vector &pt, vector &g) const
Compute the gradient of the unnormalized density at a point.
unsigned int num_components() const
Return the number of components in the mixture.
vpdt_field_default< T, n >::type vector
the data type used for vectors.
A fixed bandwidth spherical Gaussian kernel distribution.
T & vpdt_index(vnl_vector< T > &v, unsigned int i)
Index into a vnl_vector.
vpdl_kernel_gaussian_sfbw(const std::vector< vector > &samplez, T bandwid=T(1))
Constructor - from sample centers and bandwidth (variance).
void vpdt_set_size(vnl_vector< T > &v, unsigned int s)
Set the size of a vnl_vector.
The field traits class (scalar).
The base class for all probability distributions.
Overloaded functions to allow uniform API access to various field types.
virtual void compute_covar(matrix &covar) const
Compute the covariance of the distribution.
const std::vector< vector > & samples() const
Access the sample points.
virtual T norm_const() const
The normalization constant for the density.
Base classes for kernel (aka Parzen window) distributions.
void vpdt_fill(vnl_vector< T > &v, const T &val)
Fill a vnl_vector.
T box_prob(const vector &min_pt, const vector &max_pt) const
The probability of being in an axis-aligned box.
float outer_product(const float &v1, const float &v2)
vnl defines outer_product for vectors but not scalars.
A base class for fixed bandwidth kernel distributions.