23#ifndef VCL_MATH_RANDOM_H
24#define VCL_MATH_RANDOM_H
28#include <vclib/concepts/space/point.h>
60 const double SHAT1 = 2.943035529371538573;
61 const double SHAT2 = 0.8989161620588987408;
70 double pois_g = std::log(L);
75 std::uniform_real_distribution<double>
unif(0, 1);
86 if (
lf >= u * (4.0 - u) - 3.0)
88 if (u * (u -
lf) > 1.0)
90 if (2.0 * log(u) <=
lf)
98 static std::random_device rd;
99 static std::mt19937 gen(rd());
123 std::uniform_real_distribution<double>
unif(0, 1);
138 static std::random_device rd;
139 static std::mt19937 gen(rd());
153template<Po
int3Concept Po
intType>
156 using ScalarType = PointType::ScalarType;
159 std::uniform_real_distribution<ScalarType>
unif(0, 1);
172template<Po
int3Concept Po
intType>
173PointType randomTriangleBarycentricCoordinate()
175 static std::random_device rd;
176 static std::mt19937 gen(rd());
177 return randomTriangleBarycentricCoordinate<PointType>(gen);
180template<
typename ScalarType>
181std::vector<ScalarType> randomPolygonBarycentricCoordinate(
185 std::vector<ScalarType> barCoord(polySize);
188 std::uniform_real_distribution<ScalarType> unif(0, 100);
190 for (uint i = 0; i < polySize; i++) {
191 barCoord[i] = unif(gen);
194 for (uint i = 0; i < polySize; i++) {
200template<
typename ScalarType>
201std::vector<ScalarType> randomPolygonBarycentricCoordinate(uint polySize)
203 static std::random_device rd;
204 static std::mt19937 gen(rd());
205 return randomPolygonBarycentricCoordinate<ScalarType>(polySize, gen);
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
PointType randomTriangleBarycentricCoordinate(std::mt19937 &gen)
Generate the barycentric coords of a random point over a triangle, with a uniform distribution over t...
Definition random.h:154
int poissonRandomNumber(double lambda, std::mt19937 &gen)
algorithm poisson random number (Knuth): init: Let L ← e^−λ, k ← 0 and p ← 1. do: k ← k + 1....
Definition random.h:118
int poissonRatioOfUniformsInteger(double L, std::mt19937 &gen)
This subfunction generates a integer with the poisson distribution using the ratio-of-uniforms reject...
Definition random.h:57
double lnOfFactorial(int n)
Computes and caches the result of the natural logarithm of n!
Definition base.h:114