private static void multinomial_sample_test()

//****************************************************************************80
//
//  Purpose:
//
//    MULTINOMIAL_SAMPLE_TEST tests MULTINOMIAL_SAMPLE.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    12 April 2016
//
//  Author:
//
//    John Burkardt
//
    {
        const int B          = 3;
        const int SAMPLE_NUM = 1000;

        double[] c =
        {
            0.125, 0.500, 0.375
        }

        ;
        int i;
        int j;
        int seed = 123456789;

        int[] x = new int [B * SAMPLE_NUM];

        Console.WriteLine("");
        Console.WriteLine("MULTINOMIAL_SAMPLE_TEST");
        Console.WriteLine("  MULTINOMIAL_MEAN computes the Multinomial mean;");
        Console.WriteLine("  MULTINOMIAL_SAMPLE samples the Multinomial distribution;");
        Console.WriteLine("  MULTINOMIAL_VARIANCE computes the Multinomial variance;");

        int a = 5;

        Console.WriteLine("");
        Console.WriteLine("  PDF parameter A =      " + a + "");
        Console.WriteLine("  PDF parameter B =      " + B + "");
        typeMethods.r8vec_print(B, c, "  PDF parameter C:");

        if (!Multinomial.multinomial_check(a, B, c))
        {
            Console.WriteLine("");
            Console.WriteLine("MULTINOMIAL_SAMPLE_TEST - Fatal error!");
            Console.WriteLine("  The parameters are not legal.");
            return;
        }

        double[] mean     = Multinomial.multinomial_mean(a, B, c);
        double[] variance = Multinomial.multinomial_variance(a, B, c);
        typeMethods.r8vec_print(B, mean, "  PDF mean:");
        typeMethods.r8vec_print(B, variance, "  PDF variance:");

        for (j = 0; j < SAMPLE_NUM; j++)
        {
            int[] y = Multinomial.multinomial_sample(a, B, c, ref seed);
            for (i = 0; i < B; i++)
            {
                x[i + j * B] = y[i];
            }
        }

        mean     = typeMethods.i4row_mean(B, SAMPLE_NUM, x);
        variance = typeMethods.i4row_variance(B, SAMPLE_NUM, x);
        int[] xmax = typeMethods.i4row_max(B, SAMPLE_NUM, x);
        int[] xmin = typeMethods.i4row_min(B, SAMPLE_NUM, x);

        Console.WriteLine("");
        Console.WriteLine("  Sample size =     " + SAMPLE_NUM + "");
        Console.WriteLine("");
        Console.WriteLine("  Component Mean, Variance, Min, Max:");
        Console.WriteLine("");

        for (i = 0; i < B; i++)
        {
            Console.WriteLine("  "
                              + (i + 1).ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + mean[i].ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + variance[i].ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + xmin[i].ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + xmax[i].ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }