Bayesian Filtering Library Generated from SVN r
discreteconditionalpdf.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
20#ifndef __DISCRETE_CONDITIONAL_PDF__
21#define __DISCRETE_CONDITIONAL_PDF__
22
23#include "conditionalpdf.h"
24
25namespace BFL
26{
27
29
53 class DiscreteConditionalPdf : public ConditionalPdf<int, int>
54 {
55 protected:
57 unsigned int _num_states;
58
60
66
69
71 int IndexGet(const int& input, const std::vector<int>& condargs) const;
72
73 // variables to prevent memory allocation on the heap during call of
74 //SampleFrom
75 mutable std::vector<double> _probs;
76 mutable std::vector<double> _valuelist;
77
78 public:
80
90 DiscreteConditionalPdf(int num_states=1,
91 int num_conditional_arguments=1,
92 int cond_arg_dimensions[] = NULL);
97
99 virtual DiscreteConditionalPdf* Clone() const;
100
102 unsigned int NumStatesGet()const;
103
104 // Redefine all pure virtuals!
105 Probability ProbabilityGet(const int& input) const;
106 virtual bool SampleFrom (Sample<int>& one_sample, const SampleMthd method, void * args) const;
107 virtual bool SampleFrom (vector<Sample<int> >& list_samples, unsigned int num_samples, const SampleMthd method, void * args) const;
108
110 void ProbabilitySet(const double& prob, const int& input, const std::vector<int>& condargs) const;
111
112
113 };
114
115} // End namespace BFL
116
117#endif // __DISCRETE_CONDITIONAL_PDF__
Abstract Class representing conditional Pdfs P(x | ...)
Class representing all FULLY Discrete Conditional PDF's.
unsigned int _num_states
number of discrete states
int IndexGet(const int &input, const std::vector< int > &condargs) const
Get the correct index in the row of doubles (double * probability)
DiscreteConditionalPdf(const DiscreteConditionalPdf &pdf)
Copy constructor.
void ProbabilitySet(const double &prob, const int &input, const std::vector< int > &condargs) const
Set the probability (Typical for discrete Pdf's)
unsigned int NumStatesGet() const
Get the number of discrete states.
virtual ~DiscreteConditionalPdf()
Destructor.
DiscreteConditionalPdf(int num_states=1, int num_conditional_arguments=1, int cond_arg_dimensions[]=NULL)
Constructor.
int _total_dimension
Total dimension of the likelihoodtable.
double * _probability_p
Pointer to the probability values.
Probability ProbabilityGet(const int &input) const
Get the probability of a certain argument.
int * _cond_arg_dims_p
"Possible discrete states" of all the conditional arguments
virtual DiscreteConditionalPdf * Clone() const
Clone function.
Class representing a probability (a double between 0 and 1)