Nori  23
DiscretePDF Struct Reference

Discrete probability distribution. More...

#include <dpdf.h>

Public Member Functions

 DiscretePDF (size_t nEntries=0)
 Allocate memory for a distribution with the given number of entries.
 
void clear ()
 Clear all entries.
 
void reserve (size_t nEntries)
 Reserve memory for a certain number of entries.
 
void append (float pdfValue)
 Append an entry with the specified discrete probability.
 
size_t size () const
 Return the number of entries so far.
 
float operator[] (size_t entry) const
 Access an entry by its index.
 
bool isNormalized () const
 Have the probability densities been normalized?
 
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.
 

Detailed Description

Discrete probability distribution.

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

Definition at line 34 of file dpdf.h.

Member Function Documentation

◆ getNormalization()

float DiscretePDF::getNormalization ( ) const
inline

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

This assumes that normalize() has previously been called

Definition at line 88 of file dpdf.h.

◆ getSum()

float DiscretePDF::getSum ( ) const
inline

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

This assumes that normalize() has previously been called

Definition at line 79 of file dpdf.h.

◆ normalize()

float DiscretePDF::normalize ( )
inline

Normalize the distribution.

Returns
Sum of the (previously unnormalized) entries

Definition at line 97 of file dpdf.h.

◆ sample() [1/2]

size_t DiscretePDF::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

Definition at line 119 of file dpdf.h.

◆ sample() [2/2]

size_t DiscretePDF::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

Definition at line 136 of file dpdf.h.

◆ sampleReuse() [1/2]

size_t DiscretePDF::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

Definition at line 152 of file dpdf.h.

◆ sampleReuse() [2/2]

size_t DiscretePDF::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

Definition at line 171 of file dpdf.h.


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