dist_uniformtest.cpp

来自「蒙特卡洛仿真源代码很有参考价值要按照步骤进行操作」· C++ 代码 · 共 40 行

CPP
40
字号
/*Send a stream number as the first command line argument when runningthis code.  Suppose the binary of this program is named "main".  Thentype "./main 2 >> rand_2.txt".  Then run Octave and type "loadrand_2.txt".  Finally, type "hist(M)" to see a relatively flathistogram of the values produced by this program.  Slightly differenthistograms are produced by different streams, but this is to beexpected.*/#include <iostream>#include <cstdlib>#include "../include/mcsLibre.h"int main(int argc, char *argv[]){  mcsLibre mytest;  int samples = 100000;  int i;  double V;  cout << "# Created by Octave 2.1.33, Wed Feb 06 19:40:34 2002 PST <waldo@localhost.localdomain>" << endl;  cout << "# name: M" << endl;  cout << "# type: matrix" << endl;  cout << "# rows: " << samples << endl;  cout << "# columns: 1" << endl;  for (i=0; i<samples; i++)    {      V = mytest.uniform(3, 8, atoi(argv[1]));      cout << V << endl;    }  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?