Exemple #1
0
        private static void Test1_5d()
        {
            double[] data = ReadData(@"data\input1.txt");
            EM       em   = new EM(data, 3);

            em.Initialize(2);
            em.Run();
            PrintEM(em);
        }
Exemple #2
0
        private static void Test1_5a()
        {
            double[] data = ReadData(@"data\input1.txt");
            EM       em   = new EM(data, 5);

            em.Initialize(new double[5] {
                35, 12, 46, 22, 45
            });
            em.Run();
            PrintEM(em);
        }
Exemple #3
0
        private static void Test1_3()
        {
            double[] data = ReadData(@"data\input1.txt");
            EM       em   = new EM(data, 3);

            em.Initialize(new double[3] {
                21, 46, 55
            });
            em.Run();
            PrintEM(em);
        }
Exemple #4
0
        private static void Test1_5b()
        {
            double[] data = ReadData(@"data\input1.txt");
            EM       em   = new EM(data, 5);

            em.Initialize(new double[5] {
                9, 10, 46, 49, 57
            });
            em.Run();
            PrintEM(em);
        }
Exemple #5
0
        private static void BestBIC(string inputFile, int randomSeed)
        {
            double[] data = ReadData(inputFile);

            List <EM> results = new List <EM>();

            int maxK            = 5;
            int highestBICIndex = 0;

            for (int k = 0; k < maxK; k++)
            {
                EM em = new EM(data, k + 1);
                em.Initialize(randomSeed);
                em.Run();
                results.Add(em);

                // Keep track of max BIC
                if (em.BICs.Last() > results[highestBICIndex].BICs.Last())
                {
                    highestBICIndex = k;
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("k".PadLeft(6));
            sb.Append("BIC".PadLeft(14));
            sb.AppendLine();
            for (int i = 0; i < maxK; i++)
            {
                sb.Append((i + 1).ToString().PadLeft(6));
                sb.Append(results[i].BICs.Last().ToString("F6").PadLeft(14));

                if (i == highestBICIndex)
                {
                    sb.Append("  <--- Highest BIC");
                }

                sb.AppendLine();
            }
            sb.AppendLine();

            sb.Append(PrintEM(results[highestBICIndex], false));

            Console.WriteLine(sb.ToString());

            File.WriteAllText("results.txt", sb.ToString());
        }