Beispiel #1
0
    private static void weibull_cdf_test()

//****************************************************************************80
//
//  Purpose:
//
//    WEIBULL_CDF_TEST tests WEIBULL_CDF.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    06 April 2016
//
//  Author:
//
//    John Burkardt
//
    {
        int i;
        int seed = 123456789;

        Console.WriteLine("");
        Console.WriteLine("WEIBULL_CDF_TEST");
        Console.WriteLine("  WEIBULL_CDF evaluates the Weibull CDF;");
        Console.WriteLine("  WEIBULL_CDF_INV inverts the Weibull CDF.");
        Console.WriteLine("  WEIBULL_PDF evaluates the Weibull PDF;");

        double a = 2.0;
        double b = 3.0;
        double c = 4.0;

        Console.WriteLine("");
        Console.WriteLine("  PDF parameter A =      " + a + "");
        Console.WriteLine("  PDF parameter B =      " + b + "");
        Console.WriteLine("  PDF parameter C =      " + c + "");

        if (!Weibull.weibull_check(a, b, c))
        {
            Console.WriteLine("");
            Console.WriteLine("WEIBULL_CDF_TEST - Fatal error!");
            Console.WriteLine("  The parameters are not legal.");
            return;
        }

        Console.WriteLine("");
        Console.WriteLine("       X            PDF           CDF            CDF_INV");
        Console.WriteLine("");

        for (i = 1; i <= 10; i++)
        {
            double x   = Weibull.weibull_sample(a, b, c, ref seed);
            double pdf = Weibull.weibull_pdf(x, a, b, c);
            double cdf = Weibull.weibull_cdf(x, a, b, c);
            double x2  = Weibull.weibull_cdf_inv(cdf, a, b, c);

            Console.WriteLine("  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + cdf.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + x2.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }