当前位置:网站首页>生成随机高质量符合高斯分布的随机数
生成随机高质量符合高斯分布的随机数
2022-04-23 13:59:00 【流苏1990】
生成随机高质量符合高斯分布的随机数
1、C# 版本
1.1、使用如下代码(使用 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、自定义实现可以参见(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++版本
2.1、使用boost_1_75_0库
boost::normal_distribution<> nd(dAverage, dVariance);
版权声明
本文为[流苏1990]所创,转载请带上原文链接,感谢
https://blog.csdn.net/fuweiping/article/details/114383946
边栏推荐
- Chapter 15 new technologies of software engineering
- Multithreading
- 10g database cannot be started when using large memory host
- L2-024 tribe (25 points)
- MySQL [SQL performance analysis + SQL tuning]
- MySQL [acid + isolation level + redo log + undo log]
- Analysis and understanding of atomicintegerarray source code
- 剑南春把文字游戏玩明白了
- 低频量化之明日涨停预测
- 19c RAC steps for modifying VIP and scanip - same network segment
猜你喜欢
Leetcode brush question 897 incremental sequential search tree
第一章 电商秒杀商品回顾
Express middleware ③ (custom Middleware)
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
UML统一建模语言
Solution of discarding evaluate function in surprise Library
【项目】小帽外卖(八)
Modify the Jupiter notebook style
Express ② (routing)
随机推荐
crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
Move blog to CSDN
Special test 05 · double integral [Li Yanfang's whole class]
Small case of web login (including verification code login)
RAC environment error reporting ora-00239: timeout waiting for control file enqueue troubleshooting
Introduction to spark basic operation
自动化的艺术
Solution of discarding evaluate function in surprise Library
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
Oracle RAC database instance startup exception analysis IPC send timeout
Influence of openssh version on SSH mutual trust creation in RAC environment
记录一个奇怪的bug:缓存组件跳转之后出现组件复制
【项目】小帽外卖(八)
Analysis of cluster component gpnp failed to start successfully in RAC environment
Analysis and understanding of atomicintegerarray source code
L2-024 tribe (25 points)
Business case | how to promote the activity of sports and health app users? It is enough to do these points well
19c environment ora-01035 login error handling
Android 面试主题集合整理