Advertisement
luk_per

Untitled

May 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1.  void GeneratorTest(){
  2.                 int seed = 17389;
  3.                 int seed1 = 13963;
  4.                 int seed2 = 10457;
  5.                 string[] Uniform = new string[10000];
  6.                 string[] Exponential = new string[10000];
  7.                 string[] Geometric = new string[10000];
  8.                 string[] Normal = new string[10000];
  9.  
  10.  
  11.                 for (int i = 0; i < 10000; i++)
  12.                 {
  13.                     //Console.WriteLine( 500.0 + new Generator().UniformZO(ref seed) * (2500.0 - 500.0));
  14.                     Uniform[i] = Convert.ToInt32(new Generator().UniformAB(100, 200, ref seed)).ToString();
  15.                     Exponential[i] = Convert.ToInt32(new Generator().Exponential(0.0011, ref seed1)).ToString();
  16.                     Geometric[i] = Convert.ToInt32(new Generator().Geometric(0.22, ref seed2)).ToString();
  17.                     Normal[i] = new Generator().Normal(300, 0.001, ref seed).ToString();
  18.                 }
  19.  
  20.                 string pathDesktop = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
  21.                 string filePath = pathDesktop + "\\generators.csv";
  22.  
  23.                 if (!File.Exists(filePath))
  24.                 {
  25.                     File.Create(filePath).Close();
  26.                 }
  27.                 string delimter = " ";
  28.                 System.Collections.Generic.List<string[]> output = new System.Collections.Generic.List<string[]>();
  29.  
  30.        
  31.                 output.Add(Uniform);
  32.                 output.Add(Exponential);
  33.                 output.Add(Geometric);
  34.                 output.Add(Normal);
  35.  
  36.                 int length = output.Count;
  37.  
  38.                 using (System.IO.TextWriter writer = File.CreateText(filePath))
  39.                 {
  40.                     for (int index = 0; index < length; index++)
  41.                     {
  42.                         writer.WriteLine(string.Join(delimter, output[index]));
  43.                     }
  44.                 }
  45.  
  46.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement