poisson_distribution::operator()
傳回選擇性值。
template<class Engine>
result_type operator()(Engine& eng);
template<class Engine>
result_type operator()(Engine& eng,
const param_type& par0);
參數
Engine
選擇性引擎的型別。eng
選擇性引擎。par0
做為選擇性值的來源所使用的參數封裝。
備註
第 10% 成員函式使用引擎, eng 平均分散的整數值的來源並傳回與每個值發生的可能性 pr(i) = e^-stored_mean * (stored_mean^i / i!)的 i 的整數值。
第二 + 成成員函式相同的行為,不過,前者使用在 par0儲存的參數。
範例
// std_tr1__random__poisson_distribution_operator_fn.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::mt19937 Myeng;
typedef std::poisson_distribution<int, double> Mydist;
int main()
{
Myeng eng;
Mydist dist(3.5);
Mydist::input_type engval = eng();
Mydist::result_type distval = dist(eng);
distval = distval; // to quiet "unused" warnings
engval = engval;
std::cout << "mean == " << dist.mean() << std::endl;
dist.reset(); // discard any cached values
std::cout << "a random value == " << dist(eng) << std::endl;
std::cout << "a random value == " << dist(eng) << std::endl;
std::cout << "a random value == " << dist(eng) << std::endl;
return (0);
}
需求
標題: <random>
命名空間: std