Class to build vpdfl_pc_gaussian objects with a fixed number of principle components. More...
#include <vpdfl_pc_gaussian_builder.h>
Public Types | |
enum | partitionMethods { fixed, proportionate } |
Public Member Functions | |
vpdfl_pc_gaussian_builder () | |
Dflt ctor. | |
virtual | ~vpdfl_pc_gaussian_builder () |
Destructor. | |
virtual vpdfl_pdf_base * | new_model () const |
Create empty model. | |
virtual void | build (vpdfl_pdf_base &model, const vnl_vector< double > &mean) const |
Build default model with given mean. | |
virtual void | build (vpdfl_pdf_base &model, mbl_data_wrapper< vnl_vector< double > > &data) const |
Build model from data. | |
virtual void | weighted_build (vpdfl_pdf_base &model, mbl_data_wrapper< vnl_vector< double > > &data, const vcl_vector< double > &wts) const |
Build model from weighted data. | |
void | mean_covar (vnl_vector< double > &mean, vnl_matrix< double > &covar, mbl_data_wrapper< vnl_vector< double > > &data) const |
Computes mean and covariance of given data. | |
virtual unsigned | decide_partition (const vnl_vector< double > &eVals, unsigned nSamples=0, double noise=0.0) const |
Decide where to partition an Eigenvector space. | |
int | fixed_partition () const |
Return the number of principle components when using fixed partition. | |
void | set_fixed_partition (int n_principle_components) |
Set the number of principle components when using fixed partition. | |
void | set_proportion_partition (double proportion) |
Use proportion of variance to decide on the number of principle components. | |
double | proportion_partition () const |
Find the proportion of variance to decide on the number of principle components. | |
partitionMethods | partition_method () const |
How is the partition between principle and complementary spaces. | |
virtual void | config_from_stream (vcl_istream &is) |
Read initialisation settings from a stream. | |
short | version_no () const |
Version number for I/O. | |
virtual vcl_string | is_a () const |
Name of the class. | |
virtual bool | is_class (vcl_string const &s) const |
Does the name of the class match the argument?. | |
virtual vpdfl_builder_base * | clone () const |
Create a copy on the heap and return base class pointer. | |
virtual void | print_summary (vcl_ostream &os) const |
Print class to os. | |
virtual void | b_write (vsl_b_ostream &bfs) const |
Save class to binary file stream. | |
virtual void | b_read (vsl_b_istream &bfs) |
Load class from binary file stream. | |
virtual void | set_min_var (double min_var) |
Define lower threshold on variance for built models. | |
virtual double | min_var () const |
Get lower threshold on variance for built models. | |
void | meanCovar (vnl_vector< double > &mean, vnl_matrix< double > &covar, mbl_data_wrapper< vnl_vector< double > > &data) const |
Computes mean and covariance of given data. | |
void | buildFromCovar (vpdfl_gaussian &model, const vnl_vector< double > &mean, const vnl_matrix< double > &covar) const |
Build model from mean and covariance. | |
Static Public Member Functions | |
static vcl_auto_ptr < vpdfl_builder_base > | new_builder_from_stream (vcl_istream &is) |
Create a vpdfl_builder_base object given a config stream. | |
static vcl_auto_ptr < vpdfl_builder_base > | new_pdf_builder_from_stream (vcl_istream &) |
Create a vpdfl_builder_base object given a config stream (recursive style). | |
Protected Member Functions | |
void | updateCovar (vnl_matrix< double > &S, const vnl_vector< double > &v, double w) const |
Add w*v*v.transpose() to S (resizing if necessary). | |
Private Member Functions | |
vpdfl_pc_gaussian & | gaussian (vpdfl_pdf_base &model) const |
Private Attributes | |
partitionMethods | partitionMethod_ |
The method used to decide how to calculate the number of principle components. | |
double | proportionOfVariance_ |
The proportion of variance that should be encoded with the principle components. | |
unsigned | fixed_partition_ |
The number of components to represent in the principle space. |
Class to build vpdfl_pc_gaussian objects with a fixed number of principle components.
Definition at line 28 of file vpdfl_pc_gaussian_builder.h.
Definition at line 31 of file vpdfl_pc_gaussian_builder.h.
vpdfl_pc_gaussian_builder::vpdfl_pc_gaussian_builder | ( | ) |
Dflt ctor.
Definition at line 36 of file vpdfl_pc_gaussian_builder.cxx.
vpdfl_pc_gaussian_builder::~vpdfl_pc_gaussian_builder | ( | ) | [virtual] |
Destructor.
Definition at line 45 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::b_read | ( | vsl_b_istream & | bfs | ) | [virtual] |
Load class from binary file stream.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 493 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual] |
Save class to binary file stream.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 479 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::build | ( | vpdfl_pdf_base & | model, |
const vnl_vector< double > & | mean | ||
) | const [virtual] |
Build default model with given mean.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 91 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::build | ( | vpdfl_pdf_base & | model, |
mbl_data_wrapper< vnl_vector< double > > & | data | ||
) | const [virtual] |
Build model from data.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 156 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_gaussian_builder::buildFromCovar | ( | vpdfl_gaussian & | model, |
const vnl_vector< double > & | mean, | ||
const vnl_matrix< double > & | covar | ||
) | const [inherited] |
Build model from mean and covariance.
Definition at line 132 of file vpdfl_gaussian_builder.cxx.
vpdfl_builder_base * vpdfl_pc_gaussian_builder::clone | ( | ) | const [virtual] |
Create a copy on the heap and return base class pointer.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 456 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::config_from_stream | ( | vcl_istream & | is | ) | [virtual] |
Read initialisation settings from a stream.
Parameters:
{ mode_choice: fixed // Alternative: proportionate var_prop: 0.95 n_modes: 3 min_var: 1.0e-6 }
mbl_exception_parse_error | if the parse fails. |
Reimplemented from vpdfl_gaussian_builder.
Definition at line 371 of file vpdfl_pc_gaussian_builder.cxx.
unsigned vpdfl_pc_gaussian_builder::decide_partition | ( | const vnl_vector< double > & | eVals, |
unsigned | nSamples = 0 , |
||
double | noise = 0.0 |
||
) | const [virtual] |
Decide where to partition an Eigenvector space.
Returns the number of principle components to be used. Pass in the eigenvalues (eVals), the number of samples that went to make up this Gaussian (nSamples), and the noise floor for the dataset. The method may use simplified algorithms if you indicate that the number of samples or noise floor is unknown (by setting the latter parameters to 0.)
Returns the number of principle components to be used. Pass in the Eigenvalues (eVals), the number of samples that went to make up this Gaussian (nSamples), and the noise floor for the dataset. The method may use simplified algorithms if you indicate that the number of samples or noise floor is unknown (by setting the latter parameters to 0.)
Definition at line 328 of file vpdfl_pc_gaussian_builder.cxx.
int vpdfl_pc_gaussian_builder::fixed_partition | ( | ) | const [inline] |
Return the number of principle components when using fixed partition.
Definition at line 85 of file vpdfl_pc_gaussian_builder.h.
vpdfl_pc_gaussian & vpdfl_pc_gaussian_builder::gaussian | ( | vpdfl_pdf_base & | model | ) | const [private] |
Reimplemented from vpdfl_gaussian_builder.
Definition at line 75 of file vpdfl_pc_gaussian_builder.cxx.
vcl_string vpdfl_pc_gaussian_builder::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 428 of file vpdfl_pc_gaussian_builder.cxx.
bool vpdfl_pc_gaussian_builder::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Does the name of the class match the argument?.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 438 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::mean_covar | ( | vnl_vector< double > & | mean, |
vnl_matrix< double > & | covar, | ||
mbl_data_wrapper< vnl_vector< double > > & | data | ||
) | const |
Computes mean and covariance of given data.
Definition at line 205 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_gaussian_builder::meanCovar | ( | vnl_vector< double > & | mean, |
vnl_matrix< double > & | covar, | ||
mbl_data_wrapper< vnl_vector< double > > & | data | ||
) | const [inherited] |
Computes mean and covariance of given data.
Definition at line 173 of file vpdfl_gaussian_builder.cxx.
double vpdfl_gaussian_builder::min_var | ( | ) | const [virtual, inherited] |
Get lower threshold on variance for built models.
Implements vpdfl_builder_base.
Definition at line 75 of file vpdfl_gaussian_builder.cxx.
vcl_auto_ptr< vpdfl_builder_base > vpdfl_builder_base::new_builder_from_stream | ( | vcl_istream & | is | ) | [static, inherited] |
Create a vpdfl_builder_base object given a config stream.
mbl_exception | if parse error. |
vcl_runtime_exception | if parse error. |
This will store the constructed builder.
Incoming properties.
Definition at line 55 of file vpdfl_builder_base.cxx.
vpdfl_pdf_base * vpdfl_pc_gaussian_builder::new_model | ( | ) | const [virtual] |
Create empty model.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 84 of file vpdfl_pc_gaussian_builder.cxx.
vcl_auto_ptr< vpdfl_builder_base > vpdfl_builder_base::new_pdf_builder_from_stream | ( | vcl_istream & | is | ) | [static, inherited] |
Create a vpdfl_builder_base object given a config stream (recursive style).
Creates object, then uses config_from_stream(is) to set up internals
vcl_runtime_exception | if parse error. |
Creates object, then uses config_from_stream(is) to set up internals
Definition at line 145 of file vpdfl_builder_base.cxx.
partitionMethods vpdfl_pc_gaussian_builder::partition_method | ( | ) | const [inline] |
How is the partition between principle and complementary spaces.
Definition at line 108 of file vpdfl_pc_gaussian_builder.h.
void vpdfl_pc_gaussian_builder::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 465 of file vpdfl_pc_gaussian_builder.cxx.
double vpdfl_pc_gaussian_builder::proportion_partition | ( | ) | const [inline] |
Find the proportion of variance to decide on the number of principle components.
returns a negative value if not using proportion of variance method.
Definition at line 101 of file vpdfl_pc_gaussian_builder.h.
void vpdfl_pc_gaussian_builder::set_fixed_partition | ( | int | n_principle_components | ) |
Set the number of principle components when using fixed partition.
Definition at line 66 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_gaussian_builder::set_min_var | ( | double | min_var | ) | [virtual, inherited] |
Define lower threshold on variance for built models.
Implements vpdfl_builder_base.
Definition at line 68 of file vpdfl_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::set_proportion_partition | ( | double | proportion | ) |
Use proportion of variance to decide on the number of principle components.
Specify the proportion (between 0 and 1). The default setting uses a fixed number of principle components.
Definition at line 54 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_gaussian_builder::updateCovar | ( | vnl_matrix< double > & | S, |
const vnl_vector< double > & | v, | ||
double | w | ||
) | const [protected, inherited] |
Add w*v*v.transpose() to S (resizing if necessary).
By repeatedly calling this function with a new vector v and weight w You can calculate the Sum of Squares matrix.
Definition at line 102 of file vpdfl_gaussian_builder.cxx.
short vpdfl_pc_gaussian_builder::version_no | ( | ) | const |
Version number for I/O.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 447 of file vpdfl_pc_gaussian_builder.cxx.
void vpdfl_pc_gaussian_builder::weighted_build | ( | vpdfl_pdf_base & | model, |
mbl_data_wrapper< vnl_vector< double > > & | data, | ||
const vcl_vector< double > & | wts | ||
) | const [virtual] |
Build model from weighted data.
Reimplemented from vpdfl_gaussian_builder.
Definition at line 234 of file vpdfl_pc_gaussian_builder.cxx.
unsigned vpdfl_pc_gaussian_builder::fixed_partition_ [private] |
The number of components to represent in the principle space.
Definition at line 45 of file vpdfl_pc_gaussian_builder.h.
The method used to decide how to calculate the number of principle components.
defaults to fixed.
Definition at line 38 of file vpdfl_pc_gaussian_builder.h.
double vpdfl_pc_gaussian_builder::proportionOfVariance_ [private] |
The proportion of variance that should be encoded with the principle components.
Isn't used by default..
Definition at line 42 of file vpdfl_pc_gaussian_builder.h.