A class to hold samples, the window width parameter, weights for each sample, assignments of each sample to modes/cluster centers/classes. More...
#include <bsta_sample_set.h>
Public Types | |
typedef bsta_parzen_sphere< T, n >::vector_type | vector_ |
typedef vnl_matrix_fixed< T, n, n > | covar_type |
the covariance type. | |
typedef bsta_distribution< T, n >::vector_type | vect_t |
typedef bsta_distribution< T, n >::math_type | math_t |
typedef vcl_vector< vect_t > | sample_vector |
typedef sample_vector::const_iterator | sv_const_it |
enum | { dimension = n } |
The dimension of the distribution. More... | |
typedef T | math_type |
The type used for calculations. | |
typedef vnl_vector_fixed < math_type, dimension > | vector_type |
The type used for a n-dimensional vector of math types. | |
typedef vector_type | field_type |
for compatibility with vpdl/vpdt. | |
Public Member Functions | |
bsta_sample_set (T bandwidth=T(1)) | |
bool | mean (vector_ const &pt, vector_ &out) |
Compute the mean in a window around the given pt, the window size is the bandwidth. | |
void | insert_sample (vector_ const &sample, T weight=T(1.0)) |
Insert a weighted sample into the distribution. | |
T | weight (unsigned i) const |
vcl_vector< T > & | weights () |
void | normalize_weights () |
one may need to normalize the weights after the insertion is over. | |
void | initialize_assignments () |
must call this method before using the assignment vector. | |
vcl_vector< int > & | assignments () |
int | assignment (unsigned i) const |
void | set_assignment (unsigned i, int mode) |
bool | mode_mean (int mode, vector_ &out) const |
compute the mean of a particular assignment/mode/cluster. | |
vcl_vector< typename bsta_parzen_sphere< T, n > ::vector_type > ::const_iterator | samples_begin () const |
vcl_vector< typename bsta_parzen_sphere< T, n > ::vector_type > ::const_iterator | samples_end () const |
vcl_vector< T >::const_iterator | weights_begin () const |
vcl_vector< T >::const_iterator | weights_end () const |
vcl_vector< int >::const_iterator | assignments_begin () const |
vcl_vector< int >::const_iterator | assignments_end () const |
bool | check_initializations () const |
int | mode_size (int mode) const |
return number of assignments to this mode. | |
T | mode_weight (int mode) const |
return total weight of assignments to this mode. | |
unsigned | mode_cnt () const |
return number of modes in the current assignment vector. | |
T | total_weight () const |
return total weight of all assignments. | |
T | bandwidth () const |
kernel bandwidth. | |
void | set_bandwidth (T bandwidth) |
bool | bandwidth_adapted () const |
void | set_bandwidth_adapted (bool bandwidth_adapted) |
vnl_vector_fixed< T, n > | mean () const |
The mean of the distribution (just the sample mean). | |
covar_type | covar () const |
The covariance of the distribution (the sample covariance + bandwidth*I). | |
T | prob_density (vect_t const &pt) const |
The probability density at sample pt. | |
T | probability (vect_t const &min_pt, vect_t const &max_pt) const |
The probability density integrated over a box (returns a probability). | |
T | nearest_sample (const vect_t &pt, unsigned &index) const |
The distance and index of the nearest sample. | |
void | insert_sample (const vect_t &sample) |
Insert a new sample into the distribution. | |
void | insert_samples (const sample_vector &samples) |
Insert a vector of samples. | |
sample_vector | samples () const |
vect_t | sample (unsigned index) const |
bool | remove_sample (unsigned index) |
void | clear () |
clear the sample set. | |
unsigned | size () const |
number of samples. | |
Protected Attributes | |
T | bandwidth_ |
bool | bandwidth_adapted_ |
sample_vector | samples_ |
The samples. | |
Private Attributes | |
vcl_vector< T > | weights_ |
hold a vector of weights for each data sample. | |
vcl_vector< int > | assignments_ |
A class to hold samples, the window width parameter, weights for each sample, assignments of each sample to modes/cluster centers/classes.
This class is used by mean-shift and EM algorithms
Definition at line 32 of file bsta_sample_set.h.
typedef vnl_matrix_fixed<T,n,n> bsta_parzen_sphere< T, n >::covar_type [inherited] |
the covariance type.
Definition at line 35 of file bsta_parzen_sphere.h.
typedef vector_type bsta_distribution< T, n >::field_type [inherited] |
for compatibility with vpdl/vpdt.
Reimplemented in bsta_von_mises< T, n >.
Definition at line 29 of file bsta_distribution.h.
typedef bsta_distribution<T,n>::math_type bsta_parzen_sphere< T, n >::math_t [inherited] |
Definition at line 37 of file bsta_parzen_sphere.h.
typedef T bsta_distribution< T, n >::math_type [inherited] |
The type used for calculations.
Reimplemented in bsta_von_mises< T, n >.
Definition at line 25 of file bsta_distribution.h.
typedef vcl_vector<vect_t > bsta_parzen< T, n >::sample_vector [inherited] |
Definition at line 63 of file bsta_parzen.h.
typedef sample_vector::const_iterator bsta_parzen< T, n >::sv_const_it [inherited] |
Definition at line 64 of file bsta_parzen.h.
typedef bsta_distribution<T,n>::vector_type bsta_parzen_sphere< T, n >::vect_t [inherited] |
Reimplemented from bsta_parzen< T, n >.
Definition at line 36 of file bsta_parzen_sphere.h.
typedef bsta_parzen_sphere<T,n>::vector_type bsta_sample_set< T, n >::vector_ |
Definition at line 36 of file bsta_sample_set.h.
typedef vnl_vector_fixed<math_type,dimension> bsta_distribution< T, n >::vector_type [inherited] |
The type used for a n-dimensional vector of math types.
Reimplemented in bsta_von_mises< T, n >.
Definition at line 27 of file bsta_distribution.h.
anonymous enum [inherited] |
The dimension of the distribution.
Definition at line 23 of file bsta_distribution.h.
bsta_sample_set< T, n >::bsta_sample_set | ( | T | bandwidth = T(1) | ) | [inline] |
Definition at line 39 of file bsta_sample_set.h.
int bsta_sample_set< T, n >::assignment | ( | unsigned | i | ) | const [inline] |
Definition at line 57 of file bsta_sample_set.h.
vcl_vector<int>& bsta_sample_set< T, n >::assignments | ( | ) | [inline] |
Definition at line 56 of file bsta_sample_set.h.
vcl_vector<int >::const_iterator bsta_sample_set< T, n >::assignments_begin | ( | ) | const [inline] |
Definition at line 69 of file bsta_sample_set.h.
vcl_vector<int >::const_iterator bsta_sample_set< T, n >::assignments_end | ( | ) | const [inline] |
Definition at line 70 of file bsta_sample_set.h.
T bsta_parzen_sphere< T, n >::bandwidth | ( | ) | const [inline, inherited] |
kernel bandwidth.
Definition at line 48 of file bsta_parzen_sphere.h.
bool bsta_parzen_sphere< T, n >::bandwidth_adapted | ( | ) | const [inline, inherited] |
Definition at line 52 of file bsta_parzen_sphere.h.
bool bsta_sample_set< T, n >::check_initializations | ( | ) | const [inline] |
Definition at line 72 of file bsta_sample_set.h.
void bsta_parzen< T, n >::clear | ( | ) | [inline, inherited] |
clear the sample set.
Definition at line 105 of file bsta_parzen.h.
bsta_parzen_sphere< T, n >::covar_type bsta_parzen_sphere< T, n >::covar | ( | ) | const [inherited] |
The covariance of the distribution (the sample covariance + bandwidth*I).
the covariance matrix for a Parzen distribution, general case.
Definition at line 97 of file bsta_parzen_sphere.txx.
void bsta_sample_set< T, n >::initialize_assignments | ( | ) |
must call this method before using the assignment vector.
Definition at line 178 of file bsta_sample_set.txx.
void bsta_sample_set< T, n >::insert_sample | ( | vector_ const & | sample, |
T | weight = T(1.0) |
||
) |
Insert a weighted sample into the distribution.
void bsta_parzen< T, n >::insert_sample | ( | const vect_t & | sample | ) | [inline, inherited] |
Insert a new sample into the distribution.
Definition at line 79 of file bsta_parzen.h.
void bsta_parzen< T, n >::insert_samples | ( | const sample_vector & | samples | ) | [inline, inherited] |
Insert a vector of samples.
Definition at line 83 of file bsta_parzen.h.
bool bsta_sample_set< T, n >::mean | ( | vector_ const & | pt, |
vector_ & | out | ||
) |
Compute the mean in a window around the given pt, the window size is the bandwidth.
If there are no points within bandwidth of the input pt,
vnl_vector_fixed< T, n > bsta_parzen_sphere< T, n >::mean | ( | ) | const [inherited] |
The mean of the distribution (just the sample mean).
Definition at line 83 of file bsta_parzen_sphere.txx.
unsigned bsta_sample_set< T, n >::mode_cnt | ( | ) | const |
return number of modes in the current assignment vector.
Definition at line 135 of file bsta_sample_set.txx.
bool bsta_sample_set< T, n >::mode_mean | ( | int | mode, |
vector_ & | out | ||
) | const |
compute the mean of a particular assignment/mode/cluster.
Definition at line 45 of file bsta_sample_set.txx.
int bsta_sample_set< T, n >::mode_size | ( | int | mode | ) | const |
return number of assignments to this mode.
Definition at line 82 of file bsta_sample_set.txx.
T bsta_sample_set< T, n >::mode_weight | ( | int | mode | ) | const |
return total weight of assignments to this mode.
Definition at line 98 of file bsta_sample_set.txx.
T bsta_parzen_sphere< T, n >::nearest_sample | ( | const vect_t & | pt, |
unsigned & | index | ||
) | const [inherited] |
The distance and index of the nearest sample.
void bsta_sample_set< T, n >::normalize_weights | ( | ) |
one may need to normalize the weights after the insertion is over.
Definition at line 161 of file bsta_sample_set.txx.
T bsta_parzen_sphere< T, n >::prob_density | ( | vect_t const & | pt | ) | const [inherited] |
The probability density at sample pt.
T bsta_parzen_sphere< T, n >::probability | ( | vect_t const & | min_pt, |
vect_t const & | max_pt | ||
) | const [inherited] |
The probability density integrated over a box (returns a probability).
bool bsta_parzen< T, n >::remove_sample | ( | unsigned | index | ) | [inline, inherited] |
Definition at line 98 of file bsta_parzen.h.
vect_t bsta_parzen< T, n >::sample | ( | unsigned | index | ) | const [inline, inherited] |
Definition at line 92 of file bsta_parzen.h.
sample_vector bsta_parzen< T, n >::samples | ( | ) | const [inline, inherited] |
Definition at line 89 of file bsta_parzen.h.
vcl_vector<typename bsta_parzen_sphere<T,n>::vector_type >::const_iterator bsta_sample_set< T, n >::samples_begin | ( | ) | const [inline] |
Definition at line 63 of file bsta_sample_set.h.
vcl_vector<typename bsta_parzen_sphere<T,n>::vector_type >::const_iterator bsta_sample_set< T, n >::samples_end | ( | ) | const [inline] |
Definition at line 64 of file bsta_sample_set.h.
void bsta_sample_set< T, n >::set_assignment | ( | unsigned | i, |
int | mode | ||
) | [inline] |
Definition at line 58 of file bsta_sample_set.h.
void bsta_parzen_sphere< T, n >::set_bandwidth | ( | T | bandwidth | ) | [inline, inherited] |
Definition at line 50 of file bsta_parzen_sphere.h.
void bsta_parzen_sphere< T, n >::set_bandwidth_adapted | ( | bool | bandwidth_adapted | ) | [inline, inherited] |
Definition at line 54 of file bsta_parzen_sphere.h.
unsigned bsta_parzen< T, n >::size | ( | ) | const [inline, inherited] |
number of samples.
Definition at line 108 of file bsta_parzen.h.
T bsta_sample_set< T, n >::total_weight | ( | ) | const |
return total weight of all assignments.
Definition at line 118 of file bsta_sample_set.txx.
T bsta_sample_set< T, n >::weight | ( | unsigned | i | ) | const [inline] |
Definition at line 48 of file bsta_sample_set.h.
vcl_vector<T>& bsta_sample_set< T, n >::weights | ( | ) | [inline] |
Definition at line 49 of file bsta_sample_set.h.
vcl_vector<T >::const_iterator bsta_sample_set< T, n >::weights_begin | ( | ) | const [inline] |
Definition at line 66 of file bsta_sample_set.h.
vcl_vector<T >::const_iterator bsta_sample_set< T, n >::weights_end | ( | ) | const [inline] |
Definition at line 67 of file bsta_sample_set.h.
vcl_vector<int> bsta_sample_set< T, n >::assignments_ [private] |
Definition at line 93 of file bsta_sample_set.h.
T bsta_parzen_sphere< T, n >::bandwidth_ [protected, inherited] |
Definition at line 74 of file bsta_parzen_sphere.h.
bool bsta_parzen_sphere< T, n >::bandwidth_adapted_ [protected, inherited] |
Definition at line 75 of file bsta_parzen_sphere.h.
sample_vector bsta_parzen< T, n >::samples_ [protected, inherited] |
The samples.
Definition at line 68 of file bsta_parzen.h.
vcl_vector<T> bsta_sample_set< T, n >::weights_ [private] |
hold a vector of weights for each data sample.
Needs to be set separately with each insert into the data set, otherwise it's set to 1.0 by default at the first call to mean()
Definition at line 91 of file bsta_sample_set.h.