Go to the documentation of this file.
15 #ifndef ABSL_RANDOM_POISSON_DISTRIBUTION_H_
16 #define ABSL_RANDOM_POISSON_DISTRIBUTION_H_
23 #include <type_traits>
25 #include "absl/random/internal/fast_uniform_bits.h"
26 #include "absl/random/internal/fastmath.h"
27 #include "absl/random/internal/generate_real.h"
28 #include "absl/random/internal/iostream_state_saver.h"
29 #include "absl/random/internal/traits.h"
54 template <
typename IntType =
int>
67 return a.mean_ ==
b.mean_;
85 "Class-template absl::poisson_distribution<> must be "
86 "parameterized using an integral type.");
98 template <
typename URBG>
103 template <
typename URBG>
105 const param_type&
p);
117 return a.param_ ==
b.param_;
121 return a.param_ !=
b.param_;
133 template <
typename IntType>
135 : mean_(mean), split_(0) {
142 assert(
mean <= 1e10);
147 }
else if (
mean_ <= 50) {
153 constexpr
double k2E = 0.7357588823428846;
154 constexpr
double kSA = 0.4494580810294493;
158 s_ = kSA + std::sqrt(k2E *
a);
159 const double mode = std::ceil(
mean_) - 1;
164 template <
typename IntType>
165 template <
typename URBG>
192 r *= GenerateRealFromBits<double, GeneratePositiveTag, true>(
195 }
while (
r >
p.emu_);
210 const double a =
p.mean_ + 0.5;
212 const double u = GenerateRealFromBits<double, GeneratePositiveTag, false>(
214 const double v = GenerateRealFromBits<double, GenerateSignedTag, false>(
217 const double x = std::floor(
p.s_ *
v /
u +
a);
219 const double rhs =
x *
p.lmu_;
221 double s = (
x <= 1.0) ? 0.0
222 : (
x == 2.0) ? 0.693147180559945
225 const double lhs = 2.0 *
std::log(
u) +
p.log_k_ +
s;
227 return x >
static_cast<double>((
max)())
234 template <
typename CharT,
typename Traits,
typename IntType>
236 std::basic_ostream<CharT, Traits>& os,
244 template <
typename CharT,
typename Traits,
typename IntType>
246 std::basic_istream<CharT, Traits>& is,
251 double mean = random_internal::read_floating_point<double>(is);
253 x.param(param_type(
mean));
261 #endif // ABSL_RANDOM_POISSON_DISTRIBUTION_H_
istream_state_saver< std::basic_istream< CharT, Traits > > make_istream_state_saver(std::basic_istream< CharT, Traits > &is, std::ios_base::fmtflags flags=std::ios_base::dec|std::ios_base::scientific|std::ios_base::skipws)
ABSL_NAMESPACE_BEGIN std::ostream & operator<<(std::ostream &os, absl::LogSeverity s)
poisson_distribution(const param_type &p)
OPENSSL_EXPORT pem_password_cb void * u
#define ABSL_NAMESPACE_END
param_type(double mean=1.0)
RealType GenerateRealFromBits(uint64_t bits, int exp_bias=0)
#define ABSL_NAMESPACE_BEGIN
friend class poisson_distribution
result_type operator()(URBG &g)
result_type() max() const
friend bool operator!=(const param_type &a, const param_type &b)
friend bool operator==(const param_type &a, const param_type &b)
poisson_distribution(double mean)
friend bool operator==(const poisson_distribution &a, const poisson_distribution &b)
result_type() min() const
constexpr uint128 operator>>(uint128 lhs, int amount)
friend bool operator!=(const poisson_distribution &a, const poisson_distribution &b)
double StirlingLogFactorial(double n)
random_internal::FastUniformBits< uint64_t > fast_u64_
void param(const param_type &p)
ostream_state_saver< std::basic_ostream< CharT, Traits > > make_ostream_state_saver(std::basic_ostream< CharT, Traits > &os, std::ios_base::fmtflags flags=std::ios_base::dec|std::ios_base::left|std::ios_base::scientific)
static void split(const char *s, char ***ss, size_t *ns)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:44