Build Epanechnikov kernel pdf objects. More...
#include <pdf1d_epanech_kernel_pdf_builder.h>
Public Types | |
enum | build_type { fixed_width, select_equal, width_from_sep, adaptive } |
Public Member Functions | |
pdf1d_epanech_kernel_pdf_builder () | |
Dflt ctor. | |
virtual | ~pdf1d_epanech_kernel_pdf_builder () |
Destructor. | |
virtual pdf1d_pdf * | new_model () const |
Create empty model. | |
virtual vcl_string | new_model_type () const |
Name of the model class returned by new_model(). | |
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 pdf1d_builder * | 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. | |
void | set_use_fixed_width (double width) |
Use fixed width kernels of given width when building. | |
void | set_use_equal_width () |
Use equal width kernels of width depending on number of samples. | |
void | set_use_width_from_separation () |
Kernel width proportional to distance to nearby samples. | |
void | set_use_adaptive () |
Build adaptive kernel estimate. | |
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. | |
virtual void | build_from_array (pdf1d_pdf &model, const double *data, int n) const |
Build from n elements in data[i]. | |
virtual void | build (pdf1d_pdf &model, double mean) const |
Build default model with given mean. | |
virtual void | build (pdf1d_pdf &model, mbl_data_wrapper< double > &data) const |
Build model from data. | |
virtual void | weighted_build (pdf1d_pdf &model, mbl_data_wrapper< double > &data, const vcl_vector< double > &wts) const |
Build model from weighted data. | |
void | build_fixed_width (pdf1d_kernel_pdf &kpdf, const double *data, int n, double width) const |
Build from n elements in data[i]. Fixed kernel width. | |
void | build_select_equal_width (pdf1d_kernel_pdf &kpdf, const double *data, int n) const |
Build from n elements in data[i]. Chooses width. | |
void | build_width_from_separation (pdf1d_kernel_pdf &kpdf, const double *data, int n) const |
Kernel width proportional to distance to nearby samples. | |
void | build_adaptive (pdf1d_kernel_pdf &kpdf, const double *data, int n) const |
Build adaptive kernel estimate. | |
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. | |
Private Member Functions | |
pdf1d_epanech_kernel_pdf & | gkpdf (pdf1d_pdf &model) const |
Build Epanechnikov kernel pdf objects.
Build functions are implemented in the pdf1d_kernel_pdf_builder parent
Definition at line 19 of file pdf1d_epanech_kernel_pdf_builder.h.
enum pdf1d_kernel_pdf_builder::build_type [inherited] |
Definition at line 32 of file pdf1d_kernel_pdf_builder.h.
pdf1d_epanech_kernel_pdf_builder::pdf1d_epanech_kernel_pdf_builder | ( | ) |
Dflt ctor.
Definition at line 16 of file pdf1d_epanech_kernel_pdf_builder.cxx.
pdf1d_epanech_kernel_pdf_builder::~pdf1d_epanech_kernel_pdf_builder | ( | ) | [virtual] |
Destructor.
Definition at line 24 of file pdf1d_epanech_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::b_read | ( | vsl_b_istream & | bfs | ) | [virtual, inherited] |
Load class from binary file stream.
Implements pdf1d_builder.
Definition at line 308 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual, inherited] |
Save class to binary file stream.
Implements pdf1d_builder.
Definition at line 300 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build | ( | pdf1d_pdf & | model, |
double | mean | ||
) | const [virtual, inherited] |
Build default model with given mean.
Implements pdf1d_builder.
Definition at line 80 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build | ( | pdf1d_pdf & | model, |
mbl_data_wrapper< double > & | data | ||
) | const [virtual, inherited] |
Build model from data.
The kernel centres in the pdf will have same value and order as the training data
Implements pdf1d_builder.
Definition at line 126 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build_adaptive | ( | pdf1d_kernel_pdf & | kpdf, |
const double * | data, | ||
int | n | ||
) | const [inherited] |
Build adaptive kernel estimate.
Use equal widths to create a pilot estimate, then use the prob at each data point to modify the widths. Uses Silverman's equation 5.8 with alpha = 0.5 as suggested, and based on a pilot estimate as calculated by build_select_equal_width(). The kernel centres in the pdf will have same value and order as the training data.
This method gives a significantly higher density near the edges of the distribution than suggested by the cumulative histogram of the training data, pushing the cdf estimate closer to 0.5 at the edges. If you want to approximate the cumulative histogram more closely, then build_select_equal_width() may be more effective.
Use equal widths to create a pilot estimate, then use the prob at each data point to modify the widths
Definition at line 244 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build_fixed_width | ( | pdf1d_kernel_pdf & | kpdf, |
const double * | data, | ||
int | n, | ||
double | width | ||
) | const [inherited] |
Build from n elements in data[i]. Fixed kernel width.
Build from n elements in data[i].
The kernel centres in the pdf will have same value and order as the training data
Definition at line 167 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build_from_array | ( | pdf1d_pdf & | model, |
const double * | data, | ||
int | n | ||
) | const [virtual, inherited] |
Build from n elements in data[i].
Build kernel_pdf from n elements in data[i].
Reimplemented from pdf1d_builder.
Definition at line 90 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build_select_equal_width | ( | pdf1d_kernel_pdf & | kpdf, |
const double * | data, | ||
int | n | ||
) | const [inherited] |
Build from n elements in data[i]. Chooses width.
Same width selected for all points, using , as suggested by Silverman
The kernel centres in the pdf will have same value and order as the training data
Same width selected for all points, using , as suggested by Silverman
Definition at line 177 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::build_width_from_separation | ( | pdf1d_kernel_pdf & | kpdf, |
const double * | data, | ||
int | n | ||
) | const [inherited] |
Kernel width proportional to distance to nearby samples.
The kernel centres in the pdf will have same value and order as the training data
Definition at line 220 of file pdf1d_kernel_pdf_builder.cxx.
pdf1d_builder * pdf1d_epanech_kernel_pdf_builder::clone | ( | ) | const [virtual] |
Create a copy on the heap and return base class pointer.
Implements pdf1d_builder.
Definition at line 79 of file pdf1d_epanech_kernel_pdf_builder.cxx.
pdf1d_epanech_kernel_pdf & pdf1d_epanech_kernel_pdf_builder::gkpdf | ( | pdf1d_pdf & | model | ) | const [private] |
Definition at line 30 of file pdf1d_epanech_kernel_pdf_builder.cxx.
vcl_string pdf1d_epanech_kernel_pdf_builder::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented from pdf1d_kernel_pdf_builder.
Definition at line 52 of file pdf1d_epanech_kernel_pdf_builder.cxx.
bool pdf1d_epanech_kernel_pdf_builder::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Does the name of the class match the argument?.
Reimplemented from pdf1d_kernel_pdf_builder.
Definition at line 61 of file pdf1d_epanech_kernel_pdf_builder.cxx.
double pdf1d_kernel_pdf_builder::min_var | ( | ) | const [virtual, inherited] |
Get lower threshold on variance for built models.
Implements pdf1d_builder.
Definition at line 75 of file pdf1d_kernel_pdf_builder.cxx.
pdf1d_pdf * pdf1d_epanech_kernel_pdf_builder::new_model | ( | ) | const [virtual] |
Create empty model.
Implements pdf1d_builder.
Definition at line 37 of file pdf1d_epanech_kernel_pdf_builder.cxx.
vcl_string pdf1d_epanech_kernel_pdf_builder::new_model_type | ( | ) | const [virtual] |
Name of the model class returned by new_model().
Implements pdf1d_builder.
Definition at line 43 of file pdf1d_epanech_kernel_pdf_builder.cxx.
void pdf1d_epanech_kernel_pdf_builder::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Reimplemented from pdf1d_kernel_pdf_builder.
Definition at line 88 of file pdf1d_epanech_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::set_min_var | ( | double | min_var | ) | [virtual, inherited] |
Define lower threshold on variance for built models.
Implements pdf1d_builder.
Definition at line 68 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::set_use_adaptive | ( | ) | [inherited] |
Build adaptive kernel estimate.
Definition at line 61 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::set_use_equal_width | ( | ) | [inherited] |
Use equal width kernels of width depending on number of samples.
This method appears to give a lower density near the tails
Definition at line 49 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::set_use_fixed_width | ( | double | width | ) | [inherited] |
Use fixed width kernels of given width when building.
Definition at line 42 of file pdf1d_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::set_use_width_from_separation | ( | ) | [inherited] |
Kernel width proportional to distance to nearby samples.
Definition at line 55 of file pdf1d_kernel_pdf_builder.cxx.
short pdf1d_epanech_kernel_pdf_builder::version_no | ( | ) | const |
Version number for I/O.
Reimplemented from pdf1d_kernel_pdf_builder.
Definition at line 70 of file pdf1d_epanech_kernel_pdf_builder.cxx.
void pdf1d_kernel_pdf_builder::weighted_build | ( | pdf1d_pdf & | model, |
mbl_data_wrapper< double > & | data, | ||
const vcl_vector< double > & | wts | ||
) | const [virtual, inherited] |
Build model from weighted data.
Implements pdf1d_builder.
Definition at line 158 of file pdf1d_kernel_pdf_builder.cxx.