primatologist-gpl  5.0.5
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. );
45  NormalDistribution( const NormalDistribution & other );
46  virtual ~NormalDistribution();
47  NormalDistribution & operator= ( const NormalDistribution & other );
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;
96  NormalDistribution getDistribution() 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
double normal(double x, double mu, double sigma)
double _sigma
carto::VolumeRef< P > & pdf(const std::vector< Distrib > &param, const carto::VolumeRef< I > &values, carto::VolumeRef< P > &output, const carto::VolumeRef< M > &mask)
Definition: proba_d.h:205
double gauss(double x, double mu, double sigma)