当前位置:网站首页>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
边栏推荐
- Selenium IDE and XPath installation of chrome plug-in
- Use itextpdf to intercept the page to page of PDF document and divide it into pieces
- MySQL master-slave replication
- How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
- Solution of garbled code on idea console
- Xinwangda: HEV and Bev super fast charging fist products are shipped on a large scale
- oracle 中快速获取表的列名列表
- MySQL master-slave synchronization pit avoidance version tutorial
- Loading order of logback configuration file
- ◰ GL shadow map core steps
猜你喜欢
昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
面试百分百问到的进程,你究竟了解多少
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
loggie 源码分析 source file 模块主干分析
1959年高考数学真题
Set cell filling and ranking method according to the size of the value in the soft report
[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return
Detailed explanation of Niuke - Gloves
Path environment variable
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
随机推荐
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
Flask如何在内存中缓存数据?
详解牛客----手套
Getting started with JDBC
DanceNN:字节自研千亿级规模文件元数据存储系统概述
LVM与磁盘配额
New project of OMNeT learning
深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
Use case execution of robot framework
Detailed explanation of file operation (2)
批量制造测试数据的思路,附源码
Set cell filling and ranking method according to the size of the value in the soft report
Use itextpdf to intercept the page to page of PDF document and divide it into pieces
STM32__ 03 - beginner timer
Execution plan calculation for different time types
博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生
Production environment——
Quick install mongodb
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
Pytorch: the pit between train mode and eval mode