# include # include # include # include # include "asa066.h" int main ( ); void test01 ( ); void test02 ( ); void test03 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa066_test() tests asa066(). Licensing: This code is distributed under the MIT license. Modified: 01 November 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa066_test():\n" ); printf ( " C version\n" ); printf ( " Test asa066().\n" ); test01 ( ); test02 ( ); test03 ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa066_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: test01() tests alnorm(). Licensing: This code is distributed under the MIT license. Modified: 01 November 2010 Author: John Burkardt */ { double fx; double fx2; int n_data; int upper = 0; double x; printf ( "\n" ); printf ( "test01():\n" ); printf ( " Compare tabulated values of the normal\n" ); printf ( " Cumulative Density Function against values\n" ); printf ( " computed by alnorm().\n" ); printf ( "\n" ); printf ( " X CDF CDF" ); printf ( " DIFF\n" ); printf ( " (tabulated) (ALNORM)\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = alnorm ( x, upper ); printf ( " %10.4f %24.16f %24.16f %20.4e\n", x, fx, fx2, fabs ( fx - fx2 ) ); } return; } /******************************************************************************/ void test02 ( ) /******************************************************************************/ /* Purpose: test02() tests normp(). Licensing: This code is distributed under the MIT license. Modified: 01 November 2010 Author: John Burkardt */ { double fx; double fx2; int n_data; double p; double pdf; double q; double x; printf ( "\n" ); printf ( "test02():\n" ); printf ( " Compare tabulated values of the normal\n" ); printf ( " Cumulative Density Function against values\n" ); printf ( " computed by normp().\n" ); printf ( "\n" ); printf ( " X CDF CDF" ); printf ( " DIFF\n" ); printf ( " (tabulated) (NORMP)\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } normp ( x, &p, &q, &pdf ); fx2 = p; printf ( " %10.4f %24.16f %24.16f %20.4e\n", x, fx, fx2, fabs ( fx - fx2 ) ); } return; } /******************************************************************************/ void test03 ( ) /******************************************************************************/ /* Purpose: test03() tests nprob(). Licensing: This code is distributed under the MIT license. Modified: 01 November 2010 Author: John Burkardt */ { double fx; double fx2; int n_data; double p; double pdf; double q; double x; printf ( "\n" ); printf ( "test03():\n" ); printf ( " Compare tabulated values of the normal\n" ); printf ( " Cumulative Density Function against values\n" ); printf ( " computed by nprob().\n" ); printf ( "\n" ); printf ( " X CDF CDF" ); printf ( " DIFF\n" ); printf ( " (tabulated) (NPROB)\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } nprob ( x, &p, &q, &pdf ); fx2 = p; printf ( " %10.4f %24.16f %24.16f %20.4e\n", x, fx, fx2, fabs ( fx - fx2 ) ); } return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 17 June 2014 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }