aGrUM  0.13.2
Dirichlet.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 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 General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_LEARNING_DIRICHLET_H
27 #define GUM_LEARNING_DIRICHLET_H
28 
29 #include <random>
30 #include <vector>
31 
32 #include <agrum/agrum.h>
34 
35 namespace gum {
36 
37  // =========================================================================
38  // === DIRICHLET CLASS ===
39  // =========================================================================
40 
47  class Dirichlet {
48  public:
50  using param_type = std::vector< float >;
51 
53  using result_type = std::vector< float >;
54 
55  // ==========================================================================
57  // ==========================================================================
59 
65  Dirichlet(const param_type& params, unsigned int seed = GUM_RANDOMSEED);
66 
71  Dirichlet(const Dirichlet& from);
72 
77  Dirichlet(Dirichlet&& from);
78 
82  ~Dirichlet();
83 
85  // ==========================================================================
87  // ==========================================================================
89 
95  Dirichlet& operator=(const Dirichlet& from);
96 
102  Dirichlet& operator=(Dirichlet&& from);
103 
109 
116 
126  template < class URNG >
127  result_type operator()(URNG& generator, const param_type& p);
128 
130  // ==========================================================================
132  // ==========================================================================
134 
139  const param_type& param() const noexcept;
140 
146  void param(const param_type& p);
147 
154  float min() const noexcept;
155 
162  float max() const noexcept;
163 
165 
166  private:
168  std::default_random_engine __generator;
169 
172  std::gamma_distribution< float > __gamma;
173 
176  };
177 
178 } /* namespace gum */
179 
180 // include the inlined functions if necessary
181 #ifndef GUM_NO_INLINE
183 #endif /* GUM_NO_INLINE */
184 
185 // always include templates
187 
188 #endif /* GUM_LEARNING_DIRICHLET_H */
A class for sampling w.r.t.
Definition: Dirichlet.h:47
a class for sampling w.r.t.
STL namespace.
const param_type & param() const noexcept
Returns the parameters of the distribution.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Dirichlet(const param_type &params, unsigned int seed=GUM_RANDOMSEED)
Default constructor.
Definition: Dirichlet_inl.h:29
float min() const noexcept
Returns the greatest lower bound of the range of values returned by gum::Dirichlet::operator()().
std::gamma_distribution< float > __gamma
The gamma distribution used to compute the Dirichlet unnormalized samples.
Definition: Dirichlet.h:172
std::vector< float > param_type
The parameter type.
Definition: Dirichlet.h:50
std::vector< float > result_type
The type for the samples generated.
Definition: Dirichlet.h:53
std::default_random_engine __generator
The random engine used by the unform random distribution.
Definition: Dirichlet.h:168
float max() const noexcept
Returns the lowest higher bound of the range of values returned by gum::Dirichlet::operator()().
~Dirichlet()
Class destructor.
Definition: Dirichlet_inl.h:49
result_type operator()()
Returns a sample from the Dirichlet distribution.
Definition: Dirichlet_inl.h:72
param_type __params
The parameters of the distribution.
Definition: Dirichlet.h:175
Contains usefull methods for random stuff.
A class for sampling w.r.t.
Dirichlet & operator=(const Dirichlet &from)
Copy operator.
Definition: Dirichlet_inl.h:52