39 #ifndef STATISTICALMODEL_H_
40 #define STATISTICALMODEL_H_
45 #include "CommonTypes.h"
47 #include "DataManager.h"
48 #include "ModelInfo.h"
49 #include "Representer.h"
102 typedef Representer<T> RepresenterType ;
103 typedef typename RepresenterType::DatasetPointerType DatasetPointerType;
104 typedef typename RepresenterType::DatasetConstPointerType DatasetConstPointerType;
105 typedef typename RepresenterType::ValueType ValueType;
106 typedef typename RepresenterType::PointType PointType;
111 typedef unsigned PointIdType;
115 typedef std::pair<PointType, ValueType> PointValuePairType;
116 typedef std::pair<unsigned, ValueType> PointIdValuePairType;
117 typedef std::list<PointValuePairType> PointValueListType;
118 typedef std::list<PointIdValuePairType> PointIdValueListType;
148 const MatrixType& orthonormalPCABasis,
149 const VectorType& pcaVariance,
150 double noiseVariance) {
151 return new StatisticalModel(representer, m, orthonormalPCABasis, pcaVariance, noiseVariance);
162 static StatisticalModel*
Load(Representer<T>* representer,
const std::string& filename,
unsigned maxNumberOfPCAComponents = std::numeric_limits<unsigned>::max());
172 static StatisticalModel*
Load(Representer<T>* representer,
const H5::Group& modelroot,
unsigned maxNumberOfPCAComponents = std::numeric_limits<unsigned>::max());
191 void Save(
const std::string& filename)
const;
198 void Save(
const H5::Group& modelRoot)
const;
237 DatasetPointerType
DatasetToSample(DatasetConstPointerType dataset)
const;
264 DatasetPointerType
DrawMean()
const;
275 DatasetPointerType
DrawSample(
const VectorType& coefficients,
bool addNoise =
false)
const ;
285 DatasetPointerType
DrawSample(
bool addNoise =
false)
const ;
329 ValueType
DrawSampleAtPoint(
const VectorType& coefficients,
const PointType& point,
bool addNoise =
false)
const;
340 ValueType
DrawSampleAtPoint(
const VectorType& coefficients,
unsigned pointId,
bool addNoise =
false)
const;
348 MatrixType
GetJacobian(
const PointType& pt)
const ;
544 VectorType
DrawSampleVector(
const VectorType& coefficients,
bool addNoise =
false)
const ;
565 return m_representer;
573 return m_representer->GetDomain();
580 void CheckAndUpdateCachedParameters()
const;
588 StatisticalModel(
const RepresenterType* representer,
const VectorType& m,
const MatrixType& orthonormalPCABasis,
const VectorType& pcaVariance,
double noiseVariance);
600 MatrixType m_pcaBasisMatrix;
601 VectorType m_pcaVariance;
602 float m_noiseVariance;
606 mutable bool m_cachedValuesValid;
609 mutable MatrixType m_MInverseMatrix;
617 #include "StatisticalModel.hxx"
static StatisticalModel * Load(Representer< T > *representer, const std::string &filename, unsigned maxNumberOfPCAComponents=std::numeric_limits< unsigned >::max())
Definition: StatisticalModel.hxx:526
ValueType DrawSampleAtPoint(const VectorType &coefficients, const PointType &point, bool addNoise=false) const
Definition: StatisticalModel.hxx:191
VectorType ComputeCoefficientsForPointIDValues(const PointIdValueListType &pointValues, double pointValueNoiseVariance=0.0) const
Definition: StatisticalModel.hxx:310
double ComputeMahalanobisDistanceForDataset(DatasetConstPointerType dataset) const
Definition: StatisticalModel.hxx:371
const ModelInfo & GetModelInfo() const
Definition: StatisticalModel.hxx:493
A trivial representer, that does no representation at all, but works directly with vectorial data...
Definition: TrivialVectorialRepresenter.h:83
VectorType DrawSampleVector(const VectorType &coefficients, bool addNoise=false) const
Definition: StatisticalModel.hxx:170
MatrixType GetOrthonormalPCABasisMatrix() const
Definition: StatisticalModel.hxx:473
VectorType ComputeCoefficientsForSample(DatasetConstPointerType sample) const
Definition: StatisticalModel.hxx:277
float GetNoiseVariance() const
Definition: StatisticalModel.hxx:447
VectorType ComputeCoefficientsForSampleVector(const VectorType &sample) const
Definition: StatisticalModel.hxx:283
VectorType RobustlyComputeCoefficientsForDataset(DatasetConstPointerType dataset, unsigned nIterations=100, unsigned nu=6, double sigma2=1) const
Definition: StatisticalModel.hxx:379
void Delete() const
Definition: StatisticalModel.h:181
DatasetPointerType DrawPCABasisSample(unsigned componentNumber) const
Definition: StatisticalModel.hxx:157
virtual ~StatisticalModel()
Definition: StatisticalModel.hxx:73
MatrixType GetCovarianceMatrix() const
Definition: StatisticalModel.hxx:258
const VectorType & GetPCAVarianceVector() const
Definition: StatisticalModel.hxx:460
const MatrixType & GetPCABasisMatrix() const
Definition: StatisticalModel.hxx:467
void SetModelInfo(const ModelInfo &modelInfo)
Definition: StatisticalModel.hxx:486
ValueType DrawMeanAtPoint(const PointType &point) const
Definition: StatisticalModel.hxx:120
stores meta information about the model, such as e.g. the name (uri) of the datasets used to build th...
Definition: ModelInfo.h:61
const RepresenterType * GetRepresenter() const
Definition: StatisticalModel.h:564
DatasetPointerType DatasetToSample(DatasetConstPointerType dataset) const
Definition: StatisticalModel.hxx:88
DatasetPointerType DrawMean() const
Definition: StatisticalModel.hxx:112
double ComputeProbabilityOfCoefficients(const VectorType &coefficients) const
Definition: StatisticalModel.hxx:364
MatrixType GetJacobian(const PointType &pt) const
Definition: StatisticalModel.hxx:507
const DomainType & GetDomain() const
Definition: StatisticalModel.h:572
double ComputeProbabilityOfDataset(DatasetConstPointerType dataset) const
Definition: StatisticalModel.hxx:350
unsigned int GetNumberOfPrincipalComponents() const
Definition: StatisticalModel.hxx:501
VectorType ComputeCoefficientsForDataset(DatasetConstPointerType dataset) const
Definition: StatisticalModel.hxx:267
ValueType EvaluateSampleAtPoint(DatasetConstPointerType sample, unsigned ptId) const
Definition: StatisticalModel.hxx:105
double ComputeLogProbabilityOfDataset(DatasetConstPointerType dataset) const
Definition: StatisticalModel.hxx:343
MatrixType GetCovarianceAtPoint(const PointType &pt1, const PointType &pt2) const
Definition: StatisticalModel.hxx:230
const VectorType & GetMeanVector() const
Definition: StatisticalModel.hxx:454
DatasetPointerType DrawSample(const VectorType &coefficients, bool addNoise=false) const
Definition: StatisticalModel.hxx:150
A Point/Value pair that is used to specify a value at a given point.
Definition: StatisticalModel.h:100
void Save(const std::string &filename) const
Definition: StatisticalModel.hxx:620
double ComputeLogProbabilityOfCoefficients(const VectorType &coefficients) const
Definition: StatisticalModel.hxx:358
VectorType ComputeCoefficientsForPointValues(const PointValueListType &pointValues, double pointValueNoiseVariance=0.0) const
Definition: StatisticalModel.hxx:297