当前位置:网站首页>Generate random numbers with high quality and Gaussian distribution
Generate random numbers with high quality and Gaussian distribution
2022-04-23 16:53:00 【Tassel 1990】
Generate random numbers with high quality and Gaussian distribution
1、C# edition
1.1、 Use the following code ( Use MathNet.Numerics)
double[] createRandom(double mean, double stdDev, int sumCount)
{
Random rand = new Random();
MathNet.Numerics.Distributions.Normal normalDist = new Normal(mean, stdDev);
List<double> resultList = new List<double>();
for (int index = 0; index < sumCount; index++)
resultList.Add(normalDist.Sample());
return resultList.ToArray();
}
1.2、 For customized implementation, see (https://www.itranslater.com/qa/details/2325740528148677632)
Random rand = new Random(); //reuse this if you are generating many
double u1 = 1.0-rand.NextDouble(); //uniform(0,1] random doubles
double u2 = 1.0-rand.NextDouble();
double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *Math.Sin(2.0 * Math.PI * u2); //random normal(0,1)
double randNormal = mean + stdDev * randStdNormal; //random normal(mean,stdDev^2)
2、C++ edition
2.1、 Use boost_1_75_0 library
boost::normal_distribution<> nd(dAverage, dVariance);
版权声明
本文为[Tassel 1990]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231359253804.html
边栏推荐
- Bytevcharts visual chart library, I have everything you want
- Nodejs installation and environment configuration
- Detailed explanation of file operation (2)
- org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
- Dlib of face recognition framework
- vim编辑器的实时操作
- Sub database and sub table & shardingsphere
- 英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
- 【题解】[SHOI2012] 随机树
- [pimf] openharmony paper Club - what is the experience of wandering in ACM survey
猜你喜欢
文件操作详解(2)
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
Modify the test case name generated by DDT
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
OMNeT学习之新建工程
Creation of RAID disk array and RAID5
Dancenn: overview of byte self-developed 100 billion scale file metadata storage system
Set cell filling and ranking method according to the size of the value in the soft report
Selenium IDE and XPath installation of chrome plug-in
File upload and download of robot framework
随机推荐
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
MySQL master-slave replication
Query the data from 2013 to 2021, and only query the data from 2020. The solution to this problem is carried out
◰GL-着色器处理程序封装
PHP高效读大文件处理数据
计算饼状图百分比
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
Zhongang Mining: Fluorite Flotation Process
计组 | 【七 输入/输出系统】知识点与例题
Nifi fast installation and file synchronization
How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
ByteVCharts可视化图表库,你想要的我都有
PyMySQL
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
拷贝构造函数 浅拷贝与深拷贝
OMNeT学习之新建工程
UWA Pipeline 功能详解|可视化配置自动测试
File upload and download of robot framework
Rtklib 2.4.3 source code Notes