primatologist-gpl  5.1.2
normal.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2013 CEA
2  *
3  * This software and supporting documentation were developed by
4  * bioPICSEL
5  * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6  * 18, route du Panorama
7  * 92265 Fontenay-aux-Roses
8  * France
9  */
10 
11 #ifndef PRIMATOLOGIST_PROBA_NORMAL_H
12 #define PRIMATOLOGIST_PROBA_NORMAL_H
13 
14 //--- primatologist ----------------------------------------------------------
15 #include <primatologist/utility/volume.h> // vol::empty
16 //--- cartodata --------------------------------------------------------------
17 #include <cartodata/volume/volume.h> // carto::VolumeRef
18 //--- std --------------------------------------------------------------------
19 #include <vector>
20 //----------------------------------------------------------------------------
21 
22 namespace aims {
23 namespace proba {
24 
25  //==========================================================================
26  //
27  // PDF
28  //
29  //==========================================================================
30 
31  double gauss( double x, double mu, double sigma );
32  double normal( double x, double mu, double sigma );
33 
34 } // namespace proba
35 
36  //==========================================================================
37  //
38  // NORMAL DISTRIBUTION
39  //
40  //==========================================================================
42  {
43  public:
44  NormalDistribution( double mu = 0., double sigma = 1. );
48 
50  double pdf( double x ) const;
51 
52  // accessors
53  double getMu() const;
54  double getSigma() const;
55 
56  // modifiers
57  void setMu( double mu );
58  void setSigma( double sigma );
59 
60  private:
61  double _mu;
62  double _sigma;
63  };
64 
65  //==========================================================================
66  //
67  // NORMAL ESTIMATION
68  //
69  //==========================================================================
70  template <typename DataType = double,
71  typename WeightType = double,
72  typename MaskType = char>
74  {
75  public:
76  //--- constructor --------------------------------------------------------
79 
80  //--- set volumes --------------------------------------------------------
81  void setData( const carto::VolumeRef<DataType> & data = vol::empty<DataType>() );
82  void setWeight( const carto::VolumeRef<WeightType> & weight = vol::empty<WeightType>() );
83  void setMask( const carto::VolumeRef<MaskType> & mask = vol::empty<MaskType>() );
84 
85  //--- options ------------------------------------------------------------
86  void setBessel( bool bessel = true );
87  void setRobust( bool robust = true );
88  void setMultiWeights( bool multi = true );
89 
90  //--- fit ----------------------------------------------------------------
91  void fit();
92 
93  //--- results ------------------------------------------------------------
94  double getMu() const;
95  double getSigma() const;
97  std::vector<NormalDistribution> getDistributionVector() const;
98 
99  protected:
100  bool inMask( long x = 0, long y = 0, long z = 0, long t = 0 );
101  void fitOne( const carto::VolumeRef<WeightType> & volweight,
102  NormalDistribution & distrib );
103 
104  private:
105  std::vector<NormalDistribution> _distrib;
106  carto::VolumeRef<DataType> _data;
107  carto::VolumeRef<WeightType> _weight;
108  carto::VolumeRef<MaskType> _mask;
109  bool _bessel;
110  bool _robust;
111  bool _multi;
112  std::vector<float> _vs_data;
113  std::vector<float> _vs_mask;
114 
115  };
116 
117 } // namespace aims
118 
119 #endif // PRIMATOLOGIST_PROBA_NORMAL_H
NormalDistribution(const NormalDistribution &other)
double pdf(double x) const
Probability Density Function.
NormalDistribution & operator=(const NormalDistribution &other)
double getSigma() const
void setMu(double mu)
NormalDistribution(double mu=0., double sigma=1.)
void setSigma(double sigma)
void setMask(const carto::VolumeRef< MaskType > &mask=vol::empty< MaskType >())
Definition: normal_d.h:76
double getMu() const
Definition: normal_d.h:109
void setMultiWeights(bool multi=true)
Definition: normal_d.h:101
void setWeight(const carto::VolumeRef< WeightType > &weight=vol::empty< WeightType >())
Definition: normal_d.h:69
void fitOne(const carto::VolumeRef< WeightType > &volweight, NormalDistribution &distrib)
Definition: normal_d.h:185
bool inMask(long x=0, long y=0, long z=0, long t=0)
Definition: normal_d.h:137
std::vector< NormalDistribution > getDistributionVector() const
Definition: normal_d.h:129
double getSigma() const
Definition: normal_d.h:115
void setBessel(bool bessel=true)
Definition: normal_d.h:89
void setRobust(bool robust=true)
Definition: normal_d.h:95
NormalDistribution getDistribution() const
Definition: normal_d.h:122
void setData(const carto::VolumeRef< DataType > &data=vol::empty< DataType >())
Definition: normal_d.h:58
double gauss(double x, double mu, double sigma)
double normal(double x, double mu, double sigma)