# C++ named requirements:RandomNumberDistribution

< cpp‎ | named req

C++
 Language Standard Library Headers Freestanding and hosted implementations Named requirements Language support library Concepts library (C++20) Diagnostics library Utilities library Strings library Containers library Iterators library Ranges library (C++20) Algorithms library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications

C++ named requirements
Basic
 MoveAssignable(C++11) MoveConstructible(C++11) Destructible
Layout
 TrivialType(C++11) TriviallyCopyable(C++11)
 StandardLayoutType(C++11) PODType
Library-Wide
 EqualityComparable LessThanComparable Swappable(C++11) ValueSwappable(C++11) NullablePointer(C++11) Hash(C++11)
Container
Container Elements
 DefaultInsertable(C++11) CopyInsertable(C++11) MoveInsertable(C++11)
 EmplaceConstructible(C++11) Erasable(C++11)
Iterator
Stream I/O
Random Numbers
 SeedSequence(C++11) RandomNumberEngine(C++11)
 RandomNumberDistribution(C++11) UniformRandomBitGenerator(C++11) RandomNumberEngineAdaptor(C++11)
Concurrency
 BasicLockable(C++11) Lockable(C++11) TimedLockable(C++11)
 Mutex(C++11) TimedMutex(C++11) SharedMutex(C++17) SharedTimedMutex(C++14)
Other
 CharTraits RegexTraits(C++11) BitmaskType NumericType LiteralType(C++11)
 UnaryTypeTrait(C++11) BinaryTypeTrait(C++11) TransformationTrait(C++11) Clock(C++11) TrivialClock(C++11)

A RandomNumberDistribution is a function object returning random numbers according to a probability density function p(x) or a discrete probability distribution P(x
i
)
.

###  Requirements

The type D satisfies RandomNumberDistribution if

Given

• T, the type named by D::result_type
• P, the type named by D::param_type, which
• satisfies CopyConstructible
• satisfies CopyAssignable
• satisfies EqualityComparable
• has a constructor taking identical arguments as each of the constructors of D that take arguments corresponding to the distribution parameters.
• has a member function with the identical name, type, and semantics, as every member function of D that returns a parameter of the distribution
• declares a member typedef using distribution_type = D;
• d, a value of type D
• x and y, (possibly const) values of type D
• p, a (possibly const) value of type P
• g, g1, g2, lvalues of a type satisfying UniformRandomBitGenerator
• os, lvalue of a specialization of std::basic_ostream
• is, lvalue of a specialization of std::basic_istream

The following expressions must be valid and have their specified effects

Expression Type Notes Complexity
D::result_type T An arithmetic type compile-time
D::param_type P compile-time
D() creates a distribution indistinguishable from any other default-constructed D constant
D(p) creates a distribution indistinguishable from D constructed directly from the values used to construct p Same as p's construction
d.reset() void Resets the internal state of the distribution. The next call to operator() on d will not depend on values produced by any engine prior to reset(). constant
x.param() P Returns p such that D(p).param() == p No worse than D(p)
d.param(p) void Postcondition: d.param() == p No worse than D(p)
d(g) T The sequence of numbers returned by successive invocations of this call with the same g are randomly distributed according to the distribution parametrized by d.param() Amortized constant number of invocations of g
d(g,p) T The sequence of numbers returned by successive invocations of this call with the same g are randomly distributed according to the distribution parametrized by p Amortized constant number of invocations of g
x.min() T the greatest lower bound on the values potentially returned by x’s operator(), as determined by the current values of x’s parameters constant
x.max() T the least upper bound on the values potentially returned by x’s operator(), as determined by the current values of x’s parameters constant
x == y bool Establishes an equivalence relation. Returns true if x.param() == y.param() and future infinite sequences of values that would be generated by repeated invocations of x(g1) and y(g2) would be equal as long as g1 == g2. constant
x != y bool !(x == y) constant
os << x Reference to the type of os Writes a textual representation of the distribution parameters and internal state to os. The formatting flags and fill character of os are unchanged.
is >> d Reference to the type of is Restores the distribution parameters and internal state with data read from is. The formatting flags of is are unchanged. The data must have been written using a stream with the same locale, CharT and Traits stream template parameters, otherwise the behavior is undefined. If bad input is encountered, is.setstate(std::ios::failbit) is called, which may throw std::ios_base::failure. d is unchanged in that case.
{"ft_lang_label":"__label__en","ft_lang_prob":0.6745941,"math_prob":0.9553794,"size":5677,"snap":"2019-35-2019-39","text_gpt3_token_len":1361,"char_repetition_ratio":0.20518245,"word_repetition_ratio":0.2599119,"special_character_ratio":0.24361458,"punctuation_ratio":0.10021097,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9886978,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-26T05:59:50Z\",\"WARC-Record-ID\":\"<urn:uuid:31418e51-533e-4083-9f99-e8e431e3f9cf>\",\"Content-Length\":\"72260\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:adf0adf3-2407-469f-90cf-289b5b581993>\",\"WARC-Concurrent-To\":\"<urn:uuid:7b4ff7b3-78e2-4fef-a02a-a96179d95eb1>\",\"WARC-IP-Address\":\"74.114.90.46\",\"WARC-Target-URI\":\"https://en.cppreference.com/w/cpp/named_req/RandomNumberDistribution\",\"WARC-Payload-Digest\":\"sha1:YT3CJVQ5WUBQ3DKV422EJ7TZ43MHZBDM\",\"WARC-Block-Digest\":\"sha1:A3K6VQK6I53FOZQ5ENAYC6NSHDZ6ETY4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027330968.54_warc_CC-MAIN-20190826042816-20190826064816-00314.warc.gz\"}"}