private static void normal_truncated_ab_cdf_test() //****************************************************************************80 // // Purpose: // // NORMAL_TRUNCATED_AB_CDF_TEST tests NORMAL_TRUNCATED_AB_CDF. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 April 2016 // // Author: // // John Burkardt // { int i; const double a = 50.0; const double b = 150.0; const double mu = 100.0; const double s = 25.0; int seed = 123456789; Console.WriteLine(""); Console.WriteLine("NORMAL_TRUNCATED_AB_CDF_TEST"); Console.WriteLine(" NORMAL_TRUNCATED_AB_CDF evaluates the Normal Truncated AB CDF."); Console.WriteLine(" NORMAL_TRUNCATED_AB_CDF_INV inverts the Normal Truncated AB CDF."); Console.WriteLine(" NORMAL_TRUNCATED_AB_PDF evaluates the Normal Truncated AB PDF."); Console.WriteLine(""); Console.WriteLine(" The parent normal distribution has"); Console.WriteLine(" mean = " + mu + ""); Console.WriteLine(" standard deviation = " + s + ""); Console.WriteLine(" The parent distribution is truncated to"); Console.WriteLine(" the interval [" + a + "," + b + "]"); Console.WriteLine(""); Console.WriteLine(" X PDF CDF CDF_INV"); Console.WriteLine(""); for (i = 1; i <= 10; i++) { double x = Truncated.normal_truncated_ab_sample(mu, s, a, b, ref seed); double pdf = Truncated.normal_truncated_ab_pdf(x, mu, s, a, b); double cdf = CDF.normal_truncated_ab_cdf(x, mu, s, a, b); double x2 = CDF.normal_truncated_ab_cdf_inv(cdf, mu, s, a, b); Console.WriteLine(" " + x.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + cdf.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + x2.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }