18 IDistribution1DSampler::~IDistribution1DSampler() =
default;
20 double Distribution1DCauchySampler::randomSample()
const
23 std::random_device rd;
24 std::mt19937 gen(rd());
25 std::exponential_distribution<double> expDist(m_lambda);
26 double value = expDist(gen);
28 std::bernoulli_distribution bernoulliDist(0.5);
29 bool sign = bernoulliDist(gen);
37 double Distribution1DGaussSampler::randomSample()
const
40 std::random_device rd;
41 std::mt19937 gen(rd());
42 std::normal_distribution<double> normalDist(m_mean, m_stddev);
44 return normalDist(gen);
47 double Distribution1DGateSampler::randomSample()
const
50 std::random_device rd;
51 std::mt19937 gen(rd());
52 std::uniform_real_distribution<double> uniformDist(m_a, m_b);
54 return uniformDist(gen);
57 double Distribution1DTriangleSampler::randomSample()
const
59 std::random_device rd;
60 std::mt19937 gen(rd());
63 std::uniform_real_distribution<> uniformDist(0.0, 1.0);
64 double cdf_value = uniformDist(gen);
68 return (-m_omega + m_omega * std::sqrt(2 * cdf_value));
70 return (m_omega - m_omega * std::sqrt(2 * (1 - cdf_value)));
73 double Distribution1DCosineSampler::randomSample()
const
75 std::random_device rd;
76 std::mt19937 gen(rd());
79 std::uniform_real_distribution<> uniformDist(0.0, 1.0);
80 double cdf_value = uniformDist(gen);
83 double func = 0.0, funcDeriv = 0.0, x = 0.0;
91 bool convergedSoln =
false;
92 while (!convergedSoln) {
93 func = x + m_omega / M_PI * std::sin(M_PI * x / m_omega) + m_omega * (1 - 2 * cdf_value);
94 funcDeriv = 1 + std::cos(M_PI * x / m_omega);
96 x = x - func / funcDeriv;
98 if (std::abs(func / funcDeriv) < 0.001)
Defines interface class IFTDistribution1D, and children thereof.