# include # include # include # include # include "asa005.h" int main ( ); void test01 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: asa005_test() tests asa005(). Licensing: This code is distributed under the MIT license. Modified: 23 October 2010 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "asa005_test():\n" ); printf ( " C version\n" ); printf ( " Test asa005().\n" ); test01 ( ); /* Terminate. */ printf ( "\n" ); printf ( "asa005_test():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: TEST01 demonstrates the use of PRNCST. Licensing: This code is distributed under the MIT license. Modified: 23 October 2010 Author: John Burkardt */ { int df; double fx; double fx2; int ifault; double lambda; int n_data; double x; printf ( "\n" ); printf ( "TEST01:\n" ); printf ( " PRNCST computes the noncentral Student's\n" ); printf ( " Cumulative Density Function.\n" ); printf ( " Compare to tabulated values.\n" ); printf ( "\n" ); printf ( " X LAMBDA DF " ); printf ( " CDF CDF DIFF\n" ); printf ( " " ); printf ( " Tabulated PRNCST\n" ); printf ( "\n" ); n_data = 0; for ( ; ; ) { student_noncentral_cdf_values ( &n_data, &df, &lambda, &x, &fx ); if ( n_data == 0 ) { break; } fx2 = prncst ( x, df, lambda, &ifault ); printf ( " %6.2f %6.2f %2d %24.16f %24.16f %10.4e\n", x, lambda, df, fx, fx2, fabs ( fx - fx2 ) ); } return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: TIMESTAMP prints the current YMDHMS date as a time stamp. Example: 31 May 2001 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 24 September 2003 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 }