std::uniform_real_distribution<RealType>::uniform_real_distribution
来自cppreference.com
< cpp | numeric | random | uniform
real distribution
数值库
伪随机数生成
| 均匀随机位生成器 | ||||
|
(C++20)
|
||||
| 引擎及引擎适配器 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 非确定性生成器 | ||||
|
(C++11)
|
||||
| 分布 | ||||
| 均匀分布 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 伯努利分布 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 泊松分布 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 正态分布 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 采样分布 | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 种子序列 | ||||
|
(C++11)
|
||||
| C 库 | ||||
std::uniform_real_distribution
| 成员函数 | ||||
|
uniform_real_distribution::uniform_real_distribution
(C++11)
|
||||
|
(C++11)
|
||||
| 生成 | ||||
| 特征 | ||||
|
(C++11)(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| 非成员函数 | ||||
|
(C++11)(C++11)(C++20
前)
|
||||
|
(C++11)(C++11)
|
|
uniform_real_distribution()
:
uniform_real_distribution(0.0)
{ }
|
(1) | (C++11 起) |
|
explicit
uniform_real_distribution(
RealType a, RealType b =
1.0
);
|
(1) | (C++11 起) |
|
explicit
uniform_real_distribution(
const
param_type&
params );
|
(2) | (C++11 起) |
构造新的分布对象。第一版本以 a 和 b 为分布参数,第二版本以
params 为分布参数。
参数
| a | - | a 分布参数(最小值) |
| b | - | b 分布参数(最大值) |
| params | - | 分布参数集 |
注意
要求 a ≤ b 且 b-a ≤ std::numeric_limits<RealType>::max() 。
若 a == b ,则后继调用 operator()
的不接受 param_type 对象的重载将导致未定义行为。
为创建闭区间 [a,b] 上的分布,可以 std::nextafter(b, std::numeric_limits<RealType>::max()) 为第二参数。
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| P0935R0 | C++11 | 默认构造函数曾为 explicit | 使之为隐式 |