# include # include # include # include # include "asa241.h" int main ( ); void test01 ( ); void test02 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa241_test() tests asa241(). Licensing: This code is distributed under the MIT license. Modified: 19 March 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa241_test():\n" ); printf ( " C version\n" ); printf ( " Test asa241().\n" ); test01 ( ); test02 ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa241_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: test01() tests r4_normal_01_cdf_inverse(), normal_01_cdf_values(). Licensing: This code is distributed under the MIT license. Modified: 19 March 2010 Author: John Burkardt */ { double fx; float fx2; int n_data; double x; float x2; printf ( "\n" ); printf ( "test01():\n" ); printf ( " Let FX = NormalCDF ( X ).\n" ); printf ( "\n" ); printf ( " normal_01_cdf_values() returns some values of ( X, FX ).\n" ); printf ( "\n" ); printf ( " r4_normal_01_cdf_inverse() takes the value of FX, and computes an\n" ); printf ( " estimate X2, of the corresponding input argument,\n" ); printf ( " accurate to about 7 decimal places.\n" ); printf ( "\n" ); printf ( " FX X X2 DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = ( float ) ( fx ); x2 = r4_normal_01_cdf_inverse ( fx2 ); printf ( " %24.16f %24.16f %24.16f %10.6g\n", fx, x, x2, fabs ( x - x2 ) ); } return; } /******************************************************************************/ void test02 ( ) /******************************************************************************/ /* Purpose: test02() tests r8_normal_01_cdf_inverse(), normal_01_cdf_values(). Licensing: This code is distributed under the MIT license. Modified: 19 March 2010 Author: John Burkardt */ { double fx; int n_data; double x; double x2; printf ( "\n" ); printf ( "test02():\n" ); printf ( " Let FX = NormalCDF ( X ).\n" ); printf ( "\n" ); printf ( " normal_01_cdf_values() returns some values of ( X, FX ).\n" ); printf ( "\n" ); printf ( " r8_normal_01_cdf_inverse() takes the value of FX, and computes an\n" ); printf ( " estimate X2, of the corresponding input argument,\n" ); printf ( " accurate to about 16 decimal places.\n" ); printf ( "\n" ); printf ( " FX X X2 DIFF\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { normal_01_cdf_values ( &n_data, &x, &fx ); if ( n_data == 0 ) { break; } x2 = r8_normal_01_cdf_inverse ( fx ); printf ( " %24.16f %24.16f %24.16f %10.6g\n", fx, x, x2, fabs ( x - x2 ) ); } 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 }