shark::Dirichlet< RngType > Class Template Reference

Implements a Dirichlet distribution. More...

#include <shark/Rng/Dirichlet.h>

+ Inheritance diagram for shark::Dirichlet< RngType >:

Public Member Functions

 Dirichlet (RngType &rng, size_t n=3, double alpha=1)
 C'tor, associates the distribution with the given generator. More...
 
 Dirichlet (RngType &rng, const std::vector< double > &alphas)
 C'tor, associates the distribution with the given generator. More...
 
std::vector< double > operator() (size_t n, double alpha)
 Creates a temporary instance of the distribution and samples it. More...
 
std::vector< double > operator() (const std::vector< double > &alphas)
 Creates a temporary instance of the distribution and samples it. More...
 
const std::vector< double > alphas () const
 Accesses the support values. More...
 
void alphas (const std::vector< double > &newAlphas)
 Adjusts the support values. More...
 
void alphas (size_t n, double alphas)
 Adjusts the support values. More...
 
double p (const std::vector< double > &x) const
 Calculates the probability of the observation x. More...
 

Detailed Description

template<typename RngType = shark::DefaultRngType>
class shark::Dirichlet< RngType >

Implements a Dirichlet distribution.

Template Parameters
RngTypeThe underlying generator type.

Definition at line 126 of file Dirichlet.h.

Constructor & Destructor Documentation

◆ Dirichlet() [1/2]

template<typename RngType = shark::DefaultRngType>
shark::Dirichlet< RngType >::Dirichlet ( RngType &  rng,
size_t  n = 3,
double  alpha = 1 
)
inlineexplicit

C'tor, associates the distribution with the given generator.

Parameters
[in,out]rngRandom number generator.
[in]nCardinality.
[in]alphaSupport value.

Definition at line 138 of file Dirichlet.h.

◆ Dirichlet() [2/2]

template<typename RngType = shark::DefaultRngType>
shark::Dirichlet< RngType >::Dirichlet ( RngType &  rng,
const std::vector< double > &  alphas 
)
inlineexplicit

C'tor, associates the distribution with the given generator.

Parameters
[in,out]rngRandom number generator.
[in]alphasSupport values.

Definition at line 147 of file Dirichlet.h.

Member Function Documentation

◆ alphas() [1/3]

template<typename RngType = shark::DefaultRngType>
const std::vector<double> shark::Dirichlet< RngType >::alphas ( ) const
inline

Accesses the support values.

Definition at line 176 of file Dirichlet.h.

◆ alphas() [2/3]

template<typename RngType = shark::DefaultRngType>
void shark::Dirichlet< RngType >::alphas ( const std::vector< double > &  newAlphas)
inline

Adjusts the support values.

Parameters
[in]newAlphasNew support values.

Definition at line 184 of file Dirichlet.h.

◆ alphas() [3/3]

template<typename RngType = shark::DefaultRngType>
void shark::Dirichlet< RngType >::alphas ( size_t  n,
double  alphas 
)
inline

Adjusts the support values.

Parameters
[in]nNew cardinality.
[in]alphasSupport value.

Definition at line 193 of file Dirichlet.h.

References shark::Dirichlet_distribution< RealType >::alphas().

◆ operator()() [1/2]

template<typename RngType = shark::DefaultRngType>
std::vector<double> shark::Dirichlet< RngType >::operator() ( size_t  n,
double  alpha 
)
inline

Creates a temporary instance of the distribution and samples it.

Parameters
[in]nCardinality.
[in]alphaSupport value.

Definition at line 159 of file Dirichlet.h.

◆ operator()() [2/2]

template<typename RngType = shark::DefaultRngType>
std::vector<double> shark::Dirichlet< RngType >::operator() ( const std::vector< double > &  alphas)
inline

Creates a temporary instance of the distribution and samples it.

Parameters
[in]alphasSupport values.

Definition at line 168 of file Dirichlet.h.

◆ p()

template<typename RngType = shark::DefaultRngType>
double shark::Dirichlet< RngType >::p ( const std::vector< double > &  x) const
inline

Calculates the probability of the observation x.

Definition at line 200 of file Dirichlet.h.

References shark::Dirichlet_distribution< RealType >::alphas(), and remora::sum().


The documentation for this class was generated from the following file: