Bayesian Filtering Library Generated from SVN r
discretepdf.h
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
27namespace 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
45
47 vector<double> _CumPDF;
48
51
52 public:
54
56 DiscretePdf(unsigned int num_states=0);
57
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 const SampleMthd method = SampleMthd::DEFAULT,
85 void * args = NULL) const;
86 bool SampleFrom (Sample<int>& one_sample, const SampleMthd method = SampleMthd::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:35
unsigned int _num_states
The number of discrete state.
Definition: discretepdf.h:38
virtual ~DiscretePdf()
Destructor.
vector< double > _CumPDF
STL-vector containing the Cumulative PDF (for efficient sampling)
Definition: discretepdf.h:47
DiscretePdf(const DiscretePdf &)
Copy Constructor.
DiscretePdf(unsigned int num_states=0)
Constructor (dimension = number of classes) An equal probability is set for all classes.
unsigned int NumStatesGet() const
Get the number of discrete States.
vector< Probability > ProbabilitiesGet() const
Get all probabilities.
vector< Probability > * _Values_p
Pointer to the discrete PDF-values, the sum of the elements = 1.
Definition: discretepdf.h:41
Probability ProbabilityGet(const int &state) const
Implementation of virtual base class method.
bool SampleFrom(Sample< int > &one_sample, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
Draw 1 sample from the Pdf:
bool NormalizeProbs()
Normalize all the probabilities (eg. after setting a probability)
int MostProbableStateGet()
Get the index of the most probable state.
bool CumPDFUpdate()
Updates the cumPDF.
bool ProbabilitySet(int state, Probability a)
Function to change/set the probability of a single state.
bool SampleFrom(vector< Sample< int > > &list_samples, const unsigned int num_samples, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
Draw multiple samples from the Pdf (overloaded)
virtual DiscretePdf * Clone() const
Clone function.
bool ProbabilitiesSet(vector< Probability > &values)
Set all probabilities.
Class PDF: Virtual Base class representing Probability Density Functions.
Definition: pdf.h:51
Class representing a probability (a double between 0 and 1)
Definition: bfl_constants.h:38