Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
cdf< C > Struct Template Reference

CDF data structure. More...

#include <cdf.h>

Public Types

using value_type = bbm::iterable_value_t< C >
 
using index_type = index_t< value_type >
 

Public Member Functions

constexpr cdf (void)
 Trivial constructor.
 
constexpr cdf (const C &samples)
 Constructor.
 
constexpr cdf (const cdf &src)
 Copy Constructor.
 
constexpr cdf operator= (const cdf &src)
 Assigmemnt.
 
size_t size (void) const
 number of samples
 
auto sample (const value_type &xi, index_mask_t< index_type > mask=true) const
 sample the CDF given a random variable xi
 
auto pdf (const index_type &idx, index_mask_t< index_type > mask=true) const
 querry the PDF that an index will be sampled.
 

Private Attributes

std::decay_t< C > _cdf
 Data.
 

Detailed Description

template<typename C>
requires std::ranges::range<C>
struct bbm::cdf< C >

CDF data structure.

Template Parameters
C= container type to store CDF as well as to provide samples for construction.

Requires that the container 'C' is a range.

Member Typedef Documentation

◆ index_type

using index_type = index_t<value_type>

◆ value_type

Constructor & Destructor Documentation

◆ cdf() [1/3]

constexpr cdf ( void  )
inlineconstexpr

Trivial constructor.

◆ cdf() [2/3]

constexpr cdf ( const C &  samples)
inlineconstexpr

Constructor.

Parameters
samplesa iterable container of samples (in order).

The samples will be integrated into a CDF and normalized.

◆ cdf() [3/3]

constexpr cdf ( const cdf< C > &  src)
inlineconstexpr

Copy Constructor.

Member Function Documentation

◆ operator=()

constexpr cdf operator= ( const cdf< C > &  src)
inlineconstexpr

Assigmemnt.

◆ pdf()

auto pdf ( const index_type idx,
index_mask_t< index_type mask = true 
) const
inline

querry the PDF that an index will be sampled.

Parameters
idx= index to sample (must be in [0, size()-1]
mask= enable/disable lanes
Returns
the pdf, which is equivalent to the normalized sample value.

◆ sample()

auto sample ( const value_type xi,
index_mask_t< index_type mask = true 
) const
inline

sample the CDF given a random variable xi

Parameters
xi= random variable between 0 and 1
mask= enable/disable lanes.
Returns
sampled index, the pdf, and the residual

The value type and index type are determined by the container itself. The random variable is expected to be provided in the same data type as the value type of the container. Hence, if the container stores a packet type, the we also expect the random variable be given as a packet, and the index type to have the same number of channels.

The returned type is a tuple of:

  • the sampled index based on xi
  • the corresponding pdf of the sample
  • the residual, i.e., the rescaled entropy of xi that was not used to determine the sample.

◆ size()

size_t size ( void  ) const
inline

number of samples

Member Data Documentation

◆ _cdf

std::decay_t<C> _cdf
private

Data.


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