Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::DiscreteDistribution Struct Reference

Discrete probability distribution. More...

#include <mitsuba/core/pmf.h>

Public Member Functions

 DiscreteDistribution (size_t nEntries=0)
 Allocate memory for a distribution with the given number of entries. More...
 
void clear ()
 Clear all entries. More...
 
void reserve (size_t nEntries)
 Reserve memory for a certain number of entries. More...
 
void append (Float pdfValue)
 Append an entry with the specified discrete probability. More...
 
size_t size () const
 Return the number of entries so far. More...
 
Float operator[] (size_t entry) const
 Access an entry by its index. More...
 
bool isNormalized () const
 Have the probability densities been normalized? More...
 
Float getSum () const
 Return the original (unnormalized) sum of all PDF entries. More...
 
Float getNormalization () const
 Return the normalization factor (i.e. the inverse of getSum()) More...
 
Float normalize ()
 Normalize the distribution. More...
 
size_t sample (Float sampleValue) const
 Transform a uniformly distributed sample to the stored distribution More...
 
size_t sample (Float sampleValue, Float &pdf) const
 Transform a uniformly distributed sample to the stored distribution More...
 
size_t sampleReuse (Float &sampleValue) const
 Transform a uniformly distributed sample to the stored distribution More...
 
size_t sampleReuse (Float &sampleValue, Float &pdf) const
 Transform a uniformly distributed sample. More...
 
std::string toString () const
 Turn the underlying distribution into a human-readable string format. More...
 

Detailed Description

Discrete probability distribution.

This data structure can be used to transform uniformly distributed samples to a stored discrete probability distribution.

Constructor & Destructor Documentation

mitsuba::DiscreteDistribution::DiscreteDistribution ( size_t  nEntries = 0)
inlineexplicit

Allocate memory for a distribution with the given number of entries.

Member Function Documentation

void mitsuba::DiscreteDistribution::append ( Float  pdfValue)
inline

Append an entry with the specified discrete probability.

void mitsuba::DiscreteDistribution::clear ( )
inline

Clear all entries.

Float mitsuba::DiscreteDistribution::getNormalization ( ) const
inline

Return the normalization factor (i.e. the inverse of getSum())

This assumes that normalize() has previously been called

Float mitsuba::DiscreteDistribution::getSum ( ) const
inline

Return the original (unnormalized) sum of all PDF entries.

This assumes that normalize() has previously been called

bool mitsuba::DiscreteDistribution::isNormalized ( ) const
inline

Have the probability densities been normalized?

Float mitsuba::DiscreteDistribution::normalize ( )
inline

Normalize the distribution.

Throws an exception when no entries were previously added to the distribution.

Returns
Sum of the (previously unnormalized) entries
Float mitsuba::DiscreteDistribution::operator[] ( size_t  entry) const
inline

Access an entry by its index.

void mitsuba::DiscreteDistribution::reserve ( size_t  nEntries)
inline

Reserve memory for a certain number of entries.

size_t mitsuba::DiscreteDistribution::sample ( Float  sampleValue) const
inline

Transform a uniformly distributed sample to the stored distribution

Parameters
[in]sampleValueAn uniformly distributed sample on [0,1]
Returns
The discrete index associated with the sample
size_t mitsuba::DiscreteDistribution::sample ( Float  sampleValue,
Float pdf 
) const
inline

Transform a uniformly distributed sample to the stored distribution

Parameters
[in]sampleValueAn uniformly distributed sample on [0,1]
[out]pdfProbability value of the sample
Returns
The discrete index associated with the sample
size_t mitsuba::DiscreteDistribution::sampleReuse ( Float sampleValue) const
inline

Transform a uniformly distributed sample to the stored distribution

The original sample is value adjusted so that it can be "reused".

Parameters
[in,out]sampleValueAn uniformly distributed sample on [0,1]
Returns
The discrete index associated with the sample
size_t mitsuba::DiscreteDistribution::sampleReuse ( Float sampleValue,
Float pdf 
) const
inline

Transform a uniformly distributed sample.

The original sample is value adjusted so that it can be "reused".

Parameters
[in,out]Anuniformly distributed sample on [0,1]
[out]pdfProbability value of the sample
Returns
The discrete index associated with the sample
size_t mitsuba::DiscreteDistribution::size ( ) const
inline

Return the number of entries so far.

std::string mitsuba::DiscreteDistribution::toString ( ) const
inline

Turn the underlying distribution into a human-readable string format.


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