20 #if !defined(__MITSUBA_BIDIR_GEODIST2_H_)
21 #define __MITSUBA_BIDIR_GEODIST2_H_
58 m_baseNormalization = 1.0f / (
Float) (base+1);
59 m_invLogBase = 1.0f / std::log(base);
65 m_start = start - center;
67 m_offset = R(m_start - 1);
68 m_normalization = R(m_end) - m_offset;
75 if (i < m_start || i > m_end)
78 return r(i) / m_normalization;
90 return (R(i) - m_offset) / m_normalization;
95 return std::max(m_start,
96 Rinv(xi * m_normalization + m_offset)) + m_center;
101 return (m_base-1) * m_baseNormalization
102 * std::pow(m_base, - (
Float) std::abs(i));
107 return std::pow(m_base, (
Float) (i+1)) * m_baseNormalization;
109 return 1-std::pow(m_base, - (
Float) i) * m_baseNormalization;
114 if (x < m_base * m_baseNormalization)
115 result = std::log((1+m_base) * x) * m_invLogBase - 1;
117 result = -std::log((1+m_base) * (1-x)) * m_invLogBase;
118 return (
int) std::ceil(result);
121 Float m_base, m_invLogBase, m_baseNormalization;
122 Float m_normalization, m_offset;
123 int m_center, m_start, m_end;
Float r(int i) const
Definition: geodist2.h:100
int Rinv(Float x) const
Definition: geodist2.h:112
Float pmf(int i) const
Evaluate the probability mass function at position i.
Definition: geodist2.h:72
int sample(Float xi) const
Draw a position according to the probability mass function.
Definition: geodist2.h:94
Clamped two-tailed geometric distribution.
Definition: geodist2.h:54
void configure(int center, int start, int end)
Configure the domain and center of the distribution.
Definition: geodist2.h:63
Float R(int i) const
Definition: geodist2.h:105
TwoTailedGeoDistr(Float base)
Create a new two-tailed distribution for the given base constant.
Definition: geodist2.h:57
Float cdf(int i) const
Evaluate the cumulative distribution function at position i.
Definition: geodist2.h:82