discretepdf.h
Go to the documentation of this file.
1 // $Id$
2 // Copyright (C) 2002 Klaas Gadeyne <first dot last at gmail dot com>
3 // 2008 Tinne De Laet <first dot last at mech dot kuleuven dot be>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 2.1 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 #ifndef DISCRETEPDF_H
20 #define DISCRETEPDF_H
21 
22 #include "pdf.h"
23 #include "../wrappers/matrix/vector_wrapper.h"
24 #include "../wrappers/matrix/matrix_wrapper.h"
25 #include <vector>
26 
27 namespace BFL
28 {
30 
34  class DiscretePdf : public Pdf<int> // inherit abstract_template_class
35  {
36  protected:
38  unsigned int _num_states;
39 
41  vector<Probability> *_Values_p;
42 
44  bool NormalizeProbs();
45 
47  vector<double> _CumPDF;
48 
50  bool CumPDFUpdate();
51 
52  public:
54 
56  DiscretePdf(unsigned int num_states=0);
57 
59  DiscretePdf(const DiscretePdf &);
60 
62  virtual ~DiscretePdf();
63 
65  virtual DiscretePdf* Clone() const;
66 
68  unsigned int NumStatesGet()const;
69 
71  Probability ProbabilityGet(const int& state) const;
72 
74 
80  bool ProbabilitySet(int state, Probability a);
81 
82  bool SampleFrom (vector<Sample<int> >& list_samples,
83  const unsigned int num_samples,
84  int method = DEFAULT,
85  void * args = NULL) const;
86  bool SampleFrom (Sample<int>& one_sample, int method = DEFAULT, void * args = NULL) const;
87 
89  vector<Probability> ProbabilitiesGet() const;
90 
92 
96  bool ProbabilitiesSet(vector<Probability> & values);
97 
100 
101  };
102 
103 } // End namespace
104 
105 #endif // DISCRETEPDF_H
Class representing a PDF on a discrete variable.
Definition: discretepdf.h:34
virtual ~DiscretePdf()
Destructor.
Class PDF: Virtual Base class representing Probability Density Functions.
Definition: pdf.h:53
Probability ProbabilityGet(const int &state) const
Implementation of virtual base class method.
#define DEFAULT
bool ProbabilitiesSet(vector< Probability > &values)
Set all probabilities.
bool ProbabilitySet(int state, Probability a)
Function to change/set the probability of a single state.
unsigned int NumStatesGet() const
Get the number of discrete States.
unsigned int _num_states
The number of discrete state.
Definition: discretepdf.h:38
bool CumPDFUpdate()
Updates the cumPDF.
vector< Probability > * _Values_p
Pointer to the discrete PDF-values, the sum of the elements = 1.
Definition: discretepdf.h:41
vector< Probability > ProbabilitiesGet() const
Get all probabilities.
int MostProbableStateGet()
Get the index of the most probable state.
vector< double > _CumPDF
STL-vector containing the Cumulative PDF (for efficient sampling)
Definition: discretepdf.h:47
virtual DiscretePdf * Clone() const
Clone function.
Class representing a probability (a double between 0 and 1)
Definition: bfl_constants.h:39
bool NormalizeProbs()
Normalize all the probabilities (eg. after setting a probability)
bool SampleFrom(vector< Sample< int > > &list_samples, const unsigned int num_samples, int method=DEFAULT, void *args=NULL) const
DiscretePdf(unsigned int num_states=0)
Constructor (dimension = number of classes) An equal probability is set for all classes.


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Jun 10 2019 12:47:58