A local (single-point) surprise model. More...
#include <Surprise/SurpriseModel.H>
Public Member Functions | |
SurpriseModel (const double updatefac=0.5, const double sampleval=0.0, const double samplevar=1.0) | |
Constructor. | |
virtual | ~SurpriseModel () |
Virtual destructor ensures proper destruction of derived classes. | |
virtual void | reset ()=0 |
Reset to initial state. | |
virtual void | init (const double updatefac=0.5, const double sampleval=0.0, const double samplevar=1.0) |
Change intial state parameters. | |
virtual void | resetUpdFac (const double updfac) |
Reset our update factor. | |
virtual void | load (const double sampleval=0.0, const double samplevar=1.0)=0 |
Load given sample mean and variance. | |
virtual double | surprise (const SurpriseModel &sample) |
Compute surprise between us and another model. | |
virtual void | preComputeHyperParams (const SurpriseModel &sample) |
Pre compute hyper parameters before combineFrom. | |
virtual void | combineFrom (const Image< SurpriseModel > &models, const Image< float > &weights) |
Initialize us as a weighted combination of the given map of models. | |
virtual void | combineFrom (const Image< SurpriseModel > &models, const Image< float > &weights, const Point2D< int > &pos, const int width, const int height, const int offset) |
Initialize us as a weighted combination of the given map of models. | |
virtual void | setBias (const double slfac, const double ssfac, const SU_KL_BIAS klbias) |
Set up biases if needed for KL. | |
virtual double | getMean () const =0 |
get our mean | |
virtual double | getVar () const =0 |
get our variance | |
virtual double | getUpdateFac () const =0 |
get our UpdateFac | |
Protected Attributes | |
double | itsUpdateFac |
our update factor | |
double | itsInitialVal |
our initial value | |
double | itsInitialVar |
our initial variance |
A local (single-point) surprise model.
This the base class and it cannot be implemented as some of its functions are purely virtual. It defines the basic interface. See the derivative classes for actual implementations.
Definition at line 56 of file SurpriseModel.H.
SurpriseModel::SurpriseModel | ( | const double | updatefac = 0.5 , |
|
const double | sampleval = 0.0 , |
|||
const double | samplevar = 1.0 | |||
) |
Constructor.
Build a new SurpriseModel object and initialize it as if an infinitely long sequence of samples had been previously received by the model.
updatefac | factor by which the current model is combine with a new model on an update. Valid values are in [0..1] | |
sampleval | the value of the samples previously received. | |
samplevar | a variance expressing the intrinsic variability in the measurement of those samples. |
Definition at line 49 of file SurpriseModel.C.
SurpriseModel::~SurpriseModel | ( | ) | [virtual] |
Virtual destructor ensures proper destruction of derived classes.
Definition at line 55 of file SurpriseModel.C.
void SurpriseModel::combineFrom | ( | const Image< SurpriseModel > & | models, | |
const Image< float > & | weights, | |||
const Point2D< int > & | pos, | |||
const int | width, | |||
const int | height, | |||
const int | offset | |||
) | [inline, virtual] |
Initialize us as a weighted combination of the given map of models.
models | an array of models, one model at each pixel of the image. | |
weights | the weight to be given to each model. Weights should sum to 1.0 and this is not checked for here for computational efficiency. In this version, the weight image should have double+1 the width and height of the Surprise image, and the weight for the current point will be taken at the center of the weight map, etc. | |
pos | indicates the 2D coordinates of the center of the neighborhood in the Image | |
minw | is the minimum weight below which we just don't include a model in the update |
Definition at line 82 of file SurpriseModel.C.
void SurpriseModel::combineFrom | ( | const Image< SurpriseModel > & | models, | |
const Image< float > & | weights | |||
) | [inline, virtual] |
Initialize us as a weighted combination of the given map of models.
models | an array of models, one model at each pixel of the image. | |
weights | the weight to be given to each model. Weights should sum to 1.0 and this is not checked for here for computational efficiency. |
Definition at line 77 of file SurpriseModel.C.
virtual double SurpriseModel::getMean | ( | ) | const [pure virtual] |
get our mean
Implemented in SurpriseModelSG, SurpriseModelSP, SurpriseModelSP1, SurpriseModelSPC, SurpriseModelSPF, SurpriseModelCS, SurpriseModelGG, SurpriseModelPM, and SurpriseModelOD.
virtual double SurpriseModel::getUpdateFac | ( | ) | const [pure virtual] |
get our UpdateFac
Implemented in SurpriseModelSG, SurpriseModelSP, SurpriseModelSP1, SurpriseModelSPC, SurpriseModelSPF, SurpriseModelCS, SurpriseModelGG, SurpriseModelPM, and SurpriseModelOD.
virtual double SurpriseModel::getVar | ( | ) | const [pure virtual] |
get our variance
Implemented in SurpriseModelSG, SurpriseModelSP, SurpriseModelSP1, SurpriseModelSPC, SurpriseModelSPF, SurpriseModelCS, SurpriseModelGG, SurpriseModelPM, and SurpriseModelOD.
void SurpriseModel::init | ( | const double | updatefac = 0.5 , |
|
const double | sampleval = 0.0 , |
|||
const double | samplevar = 1.0 | |||
) | [inline, virtual] |
Change intial state parameters.
Reimplemented in SurpriseModelSG, SurpriseModelSP, SurpriseModelSP1, SurpriseModelSPC, SurpriseModelSPF, SurpriseModelCS, SurpriseModelGG, SurpriseModelPM, and SurpriseModelOD.
Definition at line 59 of file SurpriseModel.C.
References itsInitialVal, itsInitialVar, and itsUpdateFac.
virtual void SurpriseModel::load | ( | const double | sampleval = 0.0 , |
|
const double | samplevar = 1.0 | |||
) | [pure virtual] |
Load given sample mean and variance.
Implemented in SurpriseModelSG, SurpriseModelSP, SurpriseModelSP1, SurpriseModelSPC, SurpriseModelSPF, SurpriseModelCS, SurpriseModelGG, SurpriseModelPM, and SurpriseModelOD.
void SurpriseModel::preComputeHyperParams | ( | const SurpriseModel & | sample | ) | [inline, virtual] |
Pre compute hyper parameters before combineFrom.
Some models may need to update their hyper parameters BEFORE calling combineFrom. Particularly if the parameters have a covariance measure which must be updated before the models are combined
Definition at line 73 of file SurpriseModel.C.
virtual void SurpriseModel::reset | ( | ) | [pure virtual] |
Reset to initial state.
Implemented in SurpriseModelSG, SurpriseModelSP, SurpriseModelSP1, SurpriseModelSPC, SurpriseModelSPF, SurpriseModelCS, SurpriseModelGG, SurpriseModelPM, and SurpriseModelOD.
void SurpriseModel::resetUpdFac | ( | const double | updfac | ) | [inline, virtual] |
void SurpriseModel::setBias | ( | const double | slfac, | |
const double | ssfac, | |||
const SU_KL_BIAS | klbias | |||
) | [inline, virtual] |
Set up biases if needed for KL.
Reimplemented in SurpriseModelGG.
Definition at line 91 of file SurpriseModel.C.
double SurpriseModel::surprise | ( | const SurpriseModel & | sample | ) | [inline, virtual] |
Compute surprise between us and another model.
Surprise is the KL distance between our current model and what that model will become once we update it with the sample passed in as argument. For the update, our current model is weighted by itsUpdateFac while the new model by (1.0-itsUpdateFac). Programmer note: derived classes will not provide a direct overload of this (and other) base functions, as instead they will implement functions with basically the same syntax but using an argument of the derived class. Since an implementation is not provided for this base function, you will get an error at link time if you call the derived functions with a base-class argument.
Definition at line 69 of file SurpriseModel.C.
double SurpriseModel::itsInitialVal [protected] |
our initial value
Definition at line 151 of file SurpriseModel.H.
Referenced by init(), SurpriseModelCS::reset(), SurpriseModelSP::reset(), SurpriseModelOD::reset(), SurpriseModelSPF::reset(), SurpriseModelSPC::reset(), SurpriseModelSG::reset(), SurpriseModelPM::reset(), SurpriseModelSP1::reset(), and SurpriseModelGG::reset().
double SurpriseModel::itsInitialVar [protected] |
our initial variance
Definition at line 152 of file SurpriseModel.H.
Referenced by init(), SurpriseModelCS::reset(), SurpriseModelSP::reset(), SurpriseModelOD::reset(), SurpriseModelSPF::reset(), SurpriseModelSPC::reset(), SurpriseModelSG::reset(), SurpriseModelPM::reset(), SurpriseModelSP1::reset(), and SurpriseModelGG::reset().
double SurpriseModel::itsUpdateFac [protected] |
our update factor
Definition at line 150 of file SurpriseModel.H.
Referenced by SurpriseModelPM::combineFrom(), SurpriseModelPM::getUpdateFac(), SurpriseModelGG::getUpdateFac(), SurpriseModelOD::getUpdateFac(), SurpriseModelSP1::getUpdateFac(), SurpriseModelSPF::getUpdateFac(), SurpriseModelCS::getUpdateFac(), SurpriseModelSG::getUpdateFac(), SurpriseModelSPC::getUpdateFac(), SurpriseModelSP::getUpdateFac(), init(), SurpriseModelSPC::load(), SurpriseModelGG::load(), SurpriseModelSP1::load(), SurpriseModelCS::load(), SurpriseModelSPF::load(), SurpriseModelSP::load(), SurpriseModelPM::preComputeHyperParams(), resetUpdFac(), SurpriseModelSG::surprise(), SurpriseModelSP1::surprise(), SurpriseModelOD::surprise(), SurpriseModelSPC::surprise(), SurpriseModelSP::surprise(), SurpriseModelCS::surprise(), SurpriseModelGG::surprise(), and SurpriseModelSPF::surprise().