コード例 #1
0
    private static void runs_pdf_test()

//****************************************************************************80
//
//  Purpose:
//
//    RUNS_PDF_TEST tests RUNS_PDF.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    03 April 2016
//
//  Author:
//
//    John Burkardt
//
    {
        int n;

        Console.WriteLine("");
        Console.WriteLine("RUNS_PDF_TEST");
        Console.WriteLine("  RUNS_PDF evaluates the Runs PDF;");
        Console.WriteLine("");
        Console.WriteLine("  M is the number of symbols of one kind,");
        Console.WriteLine("  N is the number of symbols of the other kind,");
        Console.WriteLine("  R is the number of runs (sequences of one symbol)");
        Console.WriteLine("");
        Console.WriteLine("         M         N         R      PDF");
        Console.WriteLine("");

        const int m = 6;

        for (n = 0; n <= 9; n++)
        {
            Console.WriteLine("");
            double pdf_total = 0.0;

            int r;
            for (r = 1; r <= 2 * Math.Min(m, n) + 2; r++)
            {
                double pdf = Runs.runs_pdf(m, n, r);

                Console.WriteLine("  " + m.ToString(CultureInfo.InvariantCulture).PadLeft(8)
                                  + "  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(8)
                                  + "  " + r.ToString(CultureInfo.InvariantCulture).PadLeft(8)
                                  + "  " + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");

                pdf_total += pdf;
            }

            Console.WriteLine("  " + m.ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + "        "
                              + "  " + "        "
                              + "  " + pdf_total.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }