A single-Poisson/Gamma SurpriseModel with inertia. More...
#include <Surprise/SurpriseModel.H>
Public Member Functions | |
SurpriseModelPM (const double updatefac=0.5, const double sampleval=0.0, const double samplevar=1.0) | |
Constructor. See base class for details. | |
virtual | ~SurpriseModelPM () |
Virtual destructor ensures proper destruction of derived classes. | |
virtual void | reset () |
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 | load (const double sampleval, const double samplevar=1.0) |
Load given sample mean and variance. | |
virtual double | surprise (const SurpriseModelPM &other) |
Compute surprise between us and another model. | |
virtual void | preComputeHyperParams (const SurpriseModelPM &sample) |
pre compute alpha and beta terms before calling combine from | |
virtual void | combineFrom (const Image< SurpriseModelPM > &models, const Image< float > &weights) |
Initialize us as a weighted combination of the given map of models. | |
virtual void | combineFrom (const Image< SurpriseModelPM > &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 double | getMean () const |
get our mean | |
virtual double | getVar () const |
get our variance | |
virtual double | getUpdateFac () const |
get our UpdateFac | |
Protected Attributes | |
int | itsN |
our sample N | |
double | itsSample |
double | itsAlpha0 |
our current Gamma alpha | |
double | itsAlpha1 |
our current Gamma alpha | |
double | itsAlpha2 |
our current Gamma alpha | |
double | itsBeta0 |
our current Gamma beta | |
double | itsBeta1 |
our current Gamma beta | |
double | itsBeta2 |
our current Gamma beta | |
double | itsInitBeta |
Initial Value of beta. | |
double | itsExpectAlpha1 |
The expected value of alpha1. | |
double | itsExpectAlpha2 |
The expected value of alpha2. | |
double | itsXBar1 |
The estimated value of alpha1. | |
double | itsXBar2 |
The estimated value of alpha2. | |
double | itsLgamma1 |
Computing lgamma is expensive, so we keep it. | |
double | itsLgamma2 |
Computing lgamma is expensive, so we keep it. |
A single-Poisson/Gamma SurpriseModel with inertia.
This is a very simple SurpriseModel consisting of a single Gamma prior over Poisson, which is updated in a sliding-average manner.
Definition at line 636 of file SurpriseModel.H.
SurpriseModelPM::SurpriseModelPM | ( | const double | updatefac = 0.5 , |
|
const double | sampleval = 0.0 , |
|||
const double | samplevar = 1.0 | |||
) |
Constructor. See base class for details.
Definition at line 1179 of file SurpriseModel.C.
References itsAlpha0, itsAlpha1, itsAlpha2, itsBeta0, itsBeta1, itsBeta2, itsExpectAlpha1, itsExpectAlpha2, itsInitBeta, itsXBar1, and itsXBar2.
SurpriseModelPM::~SurpriseModelPM | ( | ) | [virtual] |
Virtual destructor ensures proper destruction of derived classes.
Definition at line 1201 of file SurpriseModel.C.
void SurpriseModelPM::combineFrom | ( | const Image< SurpriseModelPM > & | 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.
Definition at line 1284 of file SurpriseModel.C.
References ASSERT, Image< T >::begin(), Image< T >::coordsOk(), Image< T >::getHeight(), Image< T >::getWidth(), Point2D< T >::i, itsAlpha1, itsAlpha2, itsBeta1, itsBeta2, itsExpectAlpha1, itsExpectAlpha2, itsInitBeta, and SurpriseModel::itsUpdateFac.
void SurpriseModelPM::combineFrom | ( | const Image< SurpriseModelPM > & | models, | |
const Image< float > & | weights | |||
) | [inline, virtual] |
Initialize us as a weighted combination of the given map of models.
Definition at line 1277 of file SurpriseModel.C.
double SurpriseModelPM::getMean | ( | ) | const [inline, virtual] |
double SurpriseModelPM::getUpdateFac | ( | ) | const [inline, virtual] |
get our UpdateFac
Implements SurpriseModel.
Definition at line 1365 of file SurpriseModel.C.
References SurpriseModel::itsUpdateFac.
double SurpriseModelPM::getVar | ( | ) | const [inline, virtual] |
void SurpriseModelPM::init | ( | const double | updatefac = 0.5 , |
|
const double | sampleval = 0.0 , |
|||
const double | samplevar = 1.0 | |||
) | [inline, virtual] |
Change intial state parameters.
Reimplemented from SurpriseModel.
Definition at line 1209 of file SurpriseModel.C.
References load().
void SurpriseModelPM::load | ( | const double | sampleval, | |
const double | samplevar = 1.0 | |||
) | [inline, virtual] |
Load given sample mean and variance.
Implements SurpriseModel.
Definition at line 1218 of file SurpriseModel.C.
void SurpriseModelPM::preComputeHyperParams | ( | const SurpriseModelPM & | sample | ) | [inline, virtual] |
pre compute alpha and beta terms before calling combine from
Definition at line 1237 of file SurpriseModel.C.
References itsAlpha0, itsAlpha1, itsAlpha2, itsBeta1, itsBeta2, itsExpectAlpha1, itsExpectAlpha2, itsLgamma1, itsLgamma2, SurpriseModel::itsUpdateFac, itsXBar1, and itsXBar2.
void SurpriseModelPM::reset | ( | void | ) | [inline, virtual] |
Reset to initial state.
Implements SurpriseModel.
Definition at line 1205 of file SurpriseModel.C.
References SurpriseModel::itsInitialVal, SurpriseModel::itsInitialVar, and load().
double SurpriseModelPM::surprise | ( | const SurpriseModelPM & | other | ) | [inline, virtual] |
double SurpriseModelPM::itsAlpha0 [protected] |
our current Gamma alpha
Definition at line 685 of file SurpriseModel.H.
Referenced by preComputeHyperParams(), and SurpriseModelPM().
double SurpriseModelPM::itsAlpha1 [protected] |
our current Gamma alpha
Definition at line 686 of file SurpriseModel.H.
Referenced by combineFrom(), preComputeHyperParams(), surprise(), and SurpriseModelPM().
double SurpriseModelPM::itsAlpha2 [protected] |
our current Gamma alpha
Definition at line 687 of file SurpriseModel.H.
Referenced by combineFrom(), getMean(), getVar(), preComputeHyperParams(), surprise(), and SurpriseModelPM().
double SurpriseModelPM::itsBeta0 [protected] |
our current Gamma beta
Definition at line 688 of file SurpriseModel.H.
Referenced by SurpriseModelPM().
double SurpriseModelPM::itsBeta1 [protected] |
our current Gamma beta
Definition at line 689 of file SurpriseModel.H.
Referenced by combineFrom(), preComputeHyperParams(), surprise(), and SurpriseModelPM().
double SurpriseModelPM::itsBeta2 [protected] |
our current Gamma beta
Definition at line 690 of file SurpriseModel.H.
Referenced by combineFrom(), getMean(), getVar(), preComputeHyperParams(), surprise(), and SurpriseModelPM().
double SurpriseModelPM::itsExpectAlpha1 [protected] |
The expected value of alpha1.
Definition at line 692 of file SurpriseModel.H.
Referenced by combineFrom(), preComputeHyperParams(), and SurpriseModelPM().
double SurpriseModelPM::itsExpectAlpha2 [protected] |
The expected value of alpha2.
Definition at line 693 of file SurpriseModel.H.
Referenced by combineFrom(), preComputeHyperParams(), and SurpriseModelPM().
double SurpriseModelPM::itsInitBeta [protected] |
Initial Value of beta.
Definition at line 691 of file SurpriseModel.H.
Referenced by combineFrom(), and SurpriseModelPM().
double SurpriseModelPM::itsLgamma1 [protected] |
Computing lgamma is expensive, so we keep it.
Definition at line 696 of file SurpriseModel.H.
Referenced by preComputeHyperParams().
double SurpriseModelPM::itsLgamma2 [protected] |
Computing lgamma is expensive, so we keep it.
Definition at line 697 of file SurpriseModel.H.
Referenced by preComputeHyperParams().
int SurpriseModelPM::itsN [protected] |
our sample N
Definition at line 682 of file SurpriseModel.H.
double SurpriseModelPM::itsXBar1 [protected] |
The estimated value of alpha1.
Definition at line 694 of file SurpriseModel.H.
Referenced by preComputeHyperParams(), and SurpriseModelPM().
double SurpriseModelPM::itsXBar2 [protected] |
The estimated value of alpha2.
Definition at line 695 of file SurpriseModel.H.
Referenced by preComputeHyperParams(), and SurpriseModelPM().