C++高斯分布/正态分布源代码
Posted 大作家佚名
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C++高斯分布/正态分布源代码相关的知识,希望对你有一定的参考价值。
这里提供了三套完整源代码,直接可以
https://www.bilibili.com/read/cv19731449
源码1
注意:需要确保在 IDE 的编译器中启用了C++11支持。
#include<iostream>
#include<chrono>
#include<random>
using namespace std;
int main()
/* Create random engine with the help of seed */
unsigned seed = chrono::steady_clock::now().time_since_epoch().count();
default_random_engine e(seed);
/* declaring normal distribution object 'distN' and initializing its mean and standard deviation fields. */
/* Mean and standard deviation are distribution parameters of Normal distribution. Here, we have used mean=5, and standard deviation=2. You can take mean and standard deviation as per your choice */
normal_distribution<double> distN(5, 2);
int n;
cout << "\\nEnter no. of samples: ";
cin >> n;
cout << "\\nNormal distribution for " << n << " samples (mean=5, standard deviation=2) =>\\n";
for (int i = 1; i <= n; i++)
cout << i << ". " << distN(e) << "\\n";
//cout << distN(e) << endl;
return 0;
作者:测绘途夫 https://www.bilibili.com/read/cv19731449 出处:bilibili
效果:
以上是关于C++高斯分布/正态分布源代码的主要内容,如果未能解决你的问题,请参考以下文章
一起啃PRML - 1.2.4 The Gaussian distribution 高斯分布 正态分布