2 #ifndef vpdl_distribution_hxx_ 3 #define vpdl_distribution_hxx_ 11 # include <vcl_msvc_warnings.h> 30 template <
class T,
unsigned int n>
31 class inverse_cdf_helper
39 return vector(std::numeric_limits<T>::quiet_NaN());
44 class inverse_cdf_helper<T,1>
57 class inverse_cdf_helper<T,0>
65 return vector(dist.
dimension(), std::numeric_limits<T>::quiet_NaN());
76 template <
class T,
unsigned int n>
81 return inverse_cdf_helper<T,n>::invert(*
this, p);
88 template <
class T,
unsigned int n>
90 const vector& max_pt)
const 92 const unsigned int dim = this->dimension();
95 for (
unsigned int j=0; j<dim; ++j){
101 assert(
sizeof(
unsigned long)*8 > dim);
103 const unsigned long num_corners = 1 << dim;
107 for (
unsigned long i=0; i<num_corners; ++i)
112 bool plus = (dim%2 != 1);
114 for (
unsigned int j=0; j<dim; ++j){
115 bool is_max = (i>>j) & 1;
120 prob += cumulative_prob(corner);
122 prob -= cumulative_prob(corner);
129 #undef VPDL_DISTRIBUTION_INSTANTIATE 130 #define VPDL_DISTRIBUTION_INSTANTIATE(T,n) \ 131 template class vpdl_distribution<T,n > 134 #undef VPDL_INVERSE_CDF_INSTANTIATE 135 #define VPDL_INVERSE_CDF_INSTANTIATE(T) \ 136 template T vpdl_compute_inverse_cdf(const vpdl_distribution<T,1>& dist, double p) 138 #endif // vpdl_distribution_hxx_ T vpdl_compute_inverse_cdf(const vpdl_distribution< T, 1 > &, double)
Default implementation of numerical CDF inverse computation.
virtual T box_prob(const vector &min_pt, const vector &max_pt) const
The probability of being in an axis-aligned box.
virtual vector inverse_cdf(const T &p) const
Compute the inverse of the cumulative_prob() function.
The templated base class for all distributions.
T & vpdt_index(vnl_vector< T > &v, unsigned int i)
Index into a vnl_vector.
virtual unsigned int dimension() const =0
Return the run time dimension, which does not equal n when n==0.
The base class for all probability distributions.
Overloaded functions to allow uniform API access to various field types.