vMF sampling simplification suggested by Stephen Hill
parent
d24f953c14
commit
742400485d
|
@ -45,13 +45,8 @@ Vector VonMisesFisherDistr::sample(const Point2 &sample) const {
|
||||||
sample.x * std::sinh(m_kappa)) / m_kappa;
|
sample.x * std::sinh(m_kappa)) / m_kappa;
|
||||||
#else
|
#else
|
||||||
/* Numerically stable version */
|
/* Numerically stable version */
|
||||||
Float cosTheta;
|
Float cosTheta = 1 + (math::fastlog(sample.x +
|
||||||
if (sample.x > 0) {
|
math::fastexp(-2 * m_kappa) * (1 - sample.x))) / m_kappa;
|
||||||
cosTheta = 1 + (math::fastlog(sample.x) + math::fastlog(
|
|
||||||
1 - math::fastexp(-2*m_kappa) * ((sample.x-1) / sample.x))) / m_kappa;
|
|
||||||
} else {
|
|
||||||
cosTheta = 1 + math::fastexp(-2*m_kappa) / m_kappa;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Float sinTheta = math::safe_sqrt(1-cosTheta*cosTheta),
|
Float sinTheta = math::safe_sqrt(1-cosTheta*cosTheta),
|
||||||
|
|
Loading…
Reference in New Issue