如何在C ++ 11中创建正态整数分布? [英] How can I create a normal integer distribution in C++11?

查看:55
本文介绍了如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆