当前位置:网站首页>生成随机高质量符合高斯分布的随机数
生成随机高质量符合高斯分布的随机数
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
边栏推荐
- 函数只执行第一次的执行一次 once函数
- Oracle alarm log alert Chinese trace and trace files
- RAC environment error reporting ora-00239: timeout waiting for control file enqueue troubleshooting
- Go语言 RPC通讯
- elmo(BiLSTM-CRF+elmo)(Conll-2003 命名实体识别NER)
- Pytorch 经典卷积神经网络 LeNet
- Function executes only the once function for the first time
- Multithreading
- STM32学习记录0007——新建工程(基于寄存器版)
- What is the difference between blue-green publishing, rolling publishing and gray publishing?
猜你喜欢
蓝绿发布、滚动发布、灰度发布,有什么区别?
美联储数字货币最新进展
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
Crontab timing task output generates a large number of mail and runs out of file system inode problem processing
【项目】小帽外卖(八)
Detailed explanation of redis (Basic + data type + transaction + persistence + publish and subscribe + master-slave replication + sentinel + cache penetration, breakdown and avalanche)
Pytorch 经典卷积神经网络 LeNet
elmo(BiLSTM-CRF+elmo)(Conll-2003 命名实体识别NER)
OSS cloud storage management practice (polite experience)
程序编译调试学习记录
随机推荐
趣谈网络协议
Spark入门基本操作
[code analysis (1)] communication efficient learning of deep networks from decentralized data
项目中遇到的问题(五)操作Excel接口Poi的理解
Analysis of cluster component gpnp failed to start successfully in RAC environment
大专的我,闭关苦学 56 天,含泪拿下阿里 offer,五轮面试,六个小时灵魂拷问
VsCode-Go
力扣刷题 101. 对称二叉树
Express ② (routage)
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
Troubleshooting of expdp export error when Oracle table has logical bad blocks
Jiannanchun understood the word game
The latest development of fed digital currency
Kettle--控件解析
[code analysis (3)] communication efficient learning of deep networks from decentralized data
美联储数字货币最新进展
Move blog to CSDN
go 语言 数组,字符串,切片
Leetcode | 38 appearance array
Jenkins construction and use