AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
probfd::Distribution< typename > Class Template Reference

#include "probfd/distribution.h"

Description

template<typename>
class probfd::Distribution< typename >

A convenience class that represents a finite probability distribution.

Template Parameters
T- The item type.

Public Member Functions

void reserve (size_t capacity)
 Reserves space for capacity number of elements in the support of the distribution.
 
bool empty () const
 Checks if the distribution is in an empty state.
 
size_t size () const
 Returns the size of the support.
 
bool is_dirac (const T &t) const
 Checks if the distribution is a Dirac distribution wrt an element.
 
bool is_dirac () const
 Checks if the distribution is a Dirac distribution.
 
template<typename RandomVariable >
requires (std::invocable<RandomVariable, T>)
value_t expectation (RandomVariable rv) const
 Computes the expectation over a real random variable according to the distribution.
 
template<typename RandomVariable >
requires requires(RandomVariable& rv, const T& t) { { rv[t] } -> std::convertible_to<value_t>; }
value_t expectation (RandomVariable rv) const
 Computes the expectation over a real random variable according to the distribution.
 
void normalize (value_t scale)
 Scales all element probablities by a common factor.
 
void normalize ()
 Normalizes the probabilities of the elements to sum up to one.
 
iterator erase (iterator it)
 Removes the element-probability pair pointed to by it.
 
iterator erase (iterator it, iterator last)
 Removes a range of element-probability pairs.
 

Member Function Documentation

◆ reserve()

template<typename >
void probfd::Distribution< typename >::reserve ( size_t capacity)
inline

Reserves space for capacity number of elements in the support of the distribution.

◆ empty()

template<typename >
bool probfd::Distribution< typename >::empty ( ) const
inlinenodiscard

Checks if the distribution is in an empty state.

◆ size()

template<typename >
size_t probfd::Distribution< typename >::size ( ) const
inlinenodiscard

Returns the size of the support.

◆ is_dirac() [1/2]

template<typename >
bool probfd::Distribution< typename >::is_dirac ( const T & t) const
inline

Checks if the distribution is a Dirac distribution wrt an element.

◆ is_dirac() [2/2]

template<typename >
bool probfd::Distribution< typename >::is_dirac ( ) const
inlinenodiscard

Checks if the distribution is a Dirac distribution.

◆ expectation() [1/2]

template<typename >
template<typename RandomVariable >
requires (std::invocable<RandomVariable, T>)
value_t probfd::Distribution< typename >::expectation ( RandomVariable rv) const
inline

Computes the expectation over a real random variable according to the distribution.

◆ expectation() [2/2]

template<typename >
template<typename RandomVariable >
requires requires(RandomVariable& rv, const T& t) { { rv[t] } -> std::convertible_to<value_t>; }
value_t probfd::Distribution< typename >::expectation ( RandomVariable rv) const
inline

Computes the expectation over a real random variable according to the distribution.

◆ normalize() [1/2]

template<typename >
void probfd::Distribution< typename >::normalize ( value_t scale)
inline

Scales all element probablities by a common factor.

◆ normalize() [2/2]

template<typename >
void probfd::Distribution< typename >::normalize ( )
inline

Normalizes the probabilities of the elements to sum up to one.

◆ erase() [1/2]

template<typename >
iterator probfd::Distribution< typename >::erase ( iterator it)
inline

Removes the element-probability pair pointed to by it.

Returns
An iterator to the element-probability pair following the erased pair.

◆ erase() [2/2]

template<typename >
iterator probfd::Distribution< typename >::erase ( iterator it,
iterator last )
inline

Removes a range of element-probability pairs.

Returns
An iterator to the element-probability pair following the last erased pair.