35 #ifndef AIMS_MATH_PPCA_H 36 #define AIMS_MATH_PPCA_H 54 void doIt(
const std::list< Point3d>& selectedPoints,
55 const AimsData<T>& data,
double distanceRef = 0. ) ;
83 double& normMean )
const ;
98 int approx = int( x * 10.) ;
99 double res = (x * 10. - approx) ;
100 return ( 1. - res ) * _exp[approx] + res * _exp[approx+1] ;
131 const std::vector< std::list <Point3d> >& classes,
132 int nbOfSignificantEigenValues,
133 const std::vector<double>& PIj
134 = std::vector<double>() ) ;
139 std::vector<double>& maxProbaByClass ) ;
142 std::vector<double>& maxProbaByClass ) ;
145 bool classification(
const AimsData<T>& dynamicImage,
148 bool fuzzyClassification(
const AimsData<T>& dynamicImage,
151 double thresholdOnMaxPercentage = 0.,
152 double andersonScoreThreshold = 0.2,
159 if( classNb >= _discrElements.size() )
160 throw std::runtime_error(
"Class number exceeds number of classes") ;
162 return _discrElements[classNb].posteriorProbability(x, pX) ;
170 double weight(
double norm2,
int classe,
float tolerance ) ;
171 double wienerFilter(
double sigma2,
double norm2,
double factor ) ;
172 const std::vector< std::list< Point3d > >& _classes ;
175 std::vector<double>
_PIj ;
176 int _nbOfSignificantEigenValues ;
177 std::vector<ProbabilisticPcaElement> _discrElements ;
186 std::cerr <<
"ProbabilisticPcaElement::distance : " << std::endl ;
187 throw std::runtime_error(
"You must doIt first, parameter not yet " 192 std::cerr <<
"Invalid ppca ! "<< std::endl ;
202 for(
int i = 0 ; i < x.
dimX() ; ++i ){
204 for(
int j = 0 ; j < x.
dimX() ; ++j )
206 distance += ( x(i) -
_mean(i) ) * sum ;
211 std::cout <<
"Distance = " << distance << std::endl ;
223 std::cerr <<
"ProbabilisticPcaElement::posteriorProbability : " 225 throw std::runtime_error(
"You must doIt first, parameter not yet " 234 for(
int i = 0 ; i < x.
dimX() ; ++i ){
236 for(
int j = 0 ; j < x.
dimX() ; ++j )
238 distance += ( x(i) -
_mean(i) ) * sum ;
242 std::cout <<
"Distance = " << distance << std::endl ;
251 else if( index < 0. )
261 std::cerr <<
"ProbabilisticPcaElement::lnPosteriorProbability : " 263 throw std::runtime_error(
"You must doIt first, parameter not yet " 272 for(
int i = 0 ; i < x.
dimX() ; ++i ){
274 for(
int j = 0 ; j < x.
dimX() ; ++j )
276 distance += ( x(i) -
_mean(i) ) * sum ;
281 std::cout <<
"Distance = " << distance << std::endl ;
AimsFastAllocationData< double > _EValues
float posteriorProbability(const AimsData< double > &x, float pX, unsigned int classNb)
const AimsData< double > & eigenValues()
double exponential(double x)
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)
const AimsData< double > & mean() const
DataTypeTraits< T >::LongType sum(const Volume< T > &vol)
float norm2(const AimsVector< T, D > &v1)
double lnPosteriorProbability(const AimsData< double > &individual)
ProbabilisticPcaElement(int nbOfSignificativeEV, double PIj=1.)
const AimsData< double > & selectedEigenVectors()
short nbOfClasses() const
double normFactor() const
double noiseVariance() const
double distance(const AimsData< double > &individual)
void doIt(const AimsData< T > &individuals, double distanceRef=0.)
AimsFastAllocationData< double > _mean
AimsFastAllocationData< double > _x
AimsFastAllocationData< double > _xT
AimsFastAllocationData< double > _Wi
AimsFastAllocationData< double > _invCi
AimsFastAllocationData< double > _EVect
double posteriorProbability(const AimsData< double > &individual, double pX)
virtual ~ProbabilisticPcaElement()