std::uniform_real_distribution
cppreference.com
[] |
Google. . , . , . |
<metanoindex/>
<tbody> </tbody> template< class RealType = double > class uniform_real_distribution; |
( C++11) | |
i,
[a, b), :
Produces random floating-point values i, uniformly distributed on the interval
[a, b), that is, distributed according to the probability function:- P(i|a,b) =
.1 b a
| RealType | . , float, double, long double.
|
-
result_type
|
RealType
|
param_type
|
,
|
-
(public -) | |
(public -) | |
(C++11) |
(public -) |
' ( ) (public -) | |
B ( ) (public -) | |
(public -) | |
(public -) | |
(public -) | |
,
(C++11)(C++11)( C++20) |
() |
|
/ |
10 1 2
#include <random>
#include <iostream>
int main()
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(1, 2);
for (int n = 0; n < 10; ++n) {
std::cout << dis(gen) << ' ';
}
std::cout << '\n';
}
:
1.80829 1.15391 1.18483 1.38969 1.36094 1.0648 1.97798 1.27984 1.68261 1.57326