如何在C ++ 11中创建正态整数分布? [英] How can I create a normal integer distribution in C++11?
问题描述
正态分布: std :: normal_distribution< T>
只接受实数类型,例如 float
或 double
,为什么它不接受整数类型?
The normal distribution:
std::normal_distribution<T>
only accepts a real-valued type such as float
or double
, why doesn't it accept an integer type?
如何创建正态整数分布?
How can I create a normal integer distribution?
推荐答案
我对C ++ 11几乎一无所知,但是我了解一点数学(或者我曾经做过一点),离散的正态分布称为 n
变为无穷大时,正态分布就是二项分布.
I know next to nothing about C++11 but I know a little math (or I did at one point) and a discrete normal distribution is called a Binomial distribution. In fact a normal distribution is the binomial distribution when you let n
go to infinity.
因此,假设C ++ 11具有二项式分布,则您具有离散的正态分布.为什么不尝试 std :: binomial_distribution
?
So assuming C++11 has a binomial distribution then you have a discrete normal distribution.
Why don't you try std::binomial_distribution
?
您可能还想阅读 de Moivre–Laplace定理.
这篇关于如何在C ++ 11中创建正态整数分布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!