1 ANALYSIS INTRODUCTION 1 1. Introduction. ANALYSIS Egg Database Analysis Tools by John Walker http://www.fourmilab.ch/ This program is in the public domain. This program implements frequently-performed analyses of generic eggsummary data, in the form of a generic egganalysis class derived therefrom which adds various analytic tools and the storage to represent them and support their computation. (The generic stuff refers to the fact that all of these classes are defined as templates in which the data type used for the egg sample data is parametric. This permits analyses which wish to aggregate data or express it in other measures, for example, z scores, to avoid the round-off which forcing the egg sample to its default value of unsigned char would entail. We classify statistics computed as all egg, where we produce time series which evaluate quantities at a moment of time across all eggs reporting, and per egg, where we measure the behaviour of individual eggs across the entire time period in the data set. To use this code, you ll need to be familiar with the eggdata program; you ll probably use the cache to obtain your data sets and prepare extracts of time intervals of interest, and you ll need to understand the generic eggsummary class to access raw data. You may also wish to consult the timedate program to manipulate dates and times, and the statlib program for statistical tests on the data. In general, you can think of the development of analysis software as a process of migration of tools from specific purpose-built analysis programs such as those presented in examples, into this program as they become more widely used, and finally into eggdata if they are fundamentally applicable to the original data set. analysis_test.c 1 #define REVDATE "4th February 2002" See also section 23.
2 PROGRAM GLOBAL CONTEXT ANALYSIS 2 2. Program global context. #include "config.h" / System-dependent configuration / Preprocessor definitions Application include files 4 Class implementations 6 3. We export the class definitions for this package in the external file analysis.h that programs which use this library may include. analysis.h 3 #ifndef ANALYSIS_HEADER_DEFINES #define ANALYSIS_HEADER_DEFINES #include <math.h> / Make sure math.h is available / #include <iostream> #include <iomanip> #include <fstream> #include <exception> #include <stdexcept> #include <string> #include <vector> #include <map> using namespace std; #include <ctype.h> #include <assert.h> #include "eggdata.h" #include "timedate.h" #include "statlib.h" Class definitions 8 4. The following include files provide access to external components of the program not defined herein. Application include files 4 #include "analysis.h" / Class definitions for this package / This code is used in section 2. 5. This is a dummy placeholder for code to be compiled into the binary part of the program. At the moment, we have only template classes, so we d get an error on the reference absent this definition of the code portion. If we end up exclusively with templates, this definition and the reference below may be removed. Egg analysis utilities 5 This code is used in section 6. 6. The following classes are defined and their implementations provided. Class implementations 6 Egg analysis utilities 5 This code is used in section 2.
7 ANALYSIS EGG ANALYSIS UTILITIES 3 7. Egg analysis utilities.
4 THE EGG ANALYSIS CLASS ANALYSIS 8 8. The Egg Analysis Class. The egganalysis extends eggsummary to provide a variety of analyses of the raw sample data and output thereof. The intention is that egganalysis will implement the standard workhorse statistics, then be further extended to add exploratory measures. We slice the raw data two ways here: as a time series across all eggs reporting in a given time period and per-egg looking at the behaviour of each egg over the entire time period in the data set. As with the parent class, we define this as a template, generic egganalysis, which can be instantiated with whatever data type is required for the individual egg samples. A default instantiation with unsigned char is provided via the typedef egganalysis. Class definitions 8 template class Sample class generic egganalysis : public generic eggsummary < Sample > { public: double mean, variance, stouffer z ; double egg mean, egg stdev ; Sample egg min sample, egg max sample ; int egg num sample ; int nsamples ; private: void free all egg analysis data (void){ #define ReleaseTable (x) if ((x) Λ) { delete (x); (x) = Λ; ReleaseTable (mean ); ReleaseTable (variance ); ReleaseTable (stouffer z ); ReleaseTable (nsamples ); #undef ReleaseTable void free per egg analysis data (void){ #define ReleaseTable (x) if ((x) Λ) { delete (x); (x) = Λ; ReleaseTable (egg mean ); ReleaseTable (egg stdev ); ReleaseTable (egg min sample ); ReleaseTable (egg max sample ); ReleaseTable (egg num sample ); #undef ReleaseTable public: generic egganalysis ( ) { mean = variance = stouffer z = Λ; nsamples = Λ; egg mean = egg stdev = Λ; egg min sample = egg max sample = Λ; egg num sample = Λ; void write egg statistics CSV (string filename ); void write per egg statistics CSV (string filename );
8 ANALYSIS THE EGG ANALYSIS CLASS 5 void write deviation plot (string filename, string charttitle = "", int timeinterval = 1, int tickoffset = 0, string x axis label = "", double referenceprobability = 0.05, systemtime referenceprobabilitystarttime = systemtime(0)); generic egganalysis ( ) { free all egg analysis data ( ); free per egg analysis data ( ); void compute all egg statistics (void); void compute per egg statistics (void); ; typedef generic egganalysis < unsigned char > egganalysis ; See also sections 9, 10, 16, 17, and 18. This code is used in section 3. 9. Here we compute a time series for each time interval in the database, aggregating data across all the eggs (assuming they are synchronised). We compute: nsamples mean stouffer_z Number of eggs reporting in this second Mean value across all eggs reporting in this second Stouffer Z for eggs reporting Let v e be the sample reported by egg e for a given second, n the number of eggs which reported values this second, µ and σ the mean and standard deviation, respectively, of the samples produced by the eggs. Then the values tabulated are as follows: nsamples mean stouffer_z n n e=0 ve n n mean µ e=0 σ/ n Class definitions 8 + template class Sample void generic egganalysis Sample :: compute all egg statistics (void){ assert ( generic eggsummary < Sample > ::seconds per row ) ; / If this pops, you probably forgot to load the data / int nitems = generic eggsummary < Sample > :: seconds of data /generic eggsummary < Sample > ::seconds per row ; free all egg analysis data ( ); mean = new double[nitems ]; variance = new double[nitems ]; stouffer z = new double[nitems ]; nsamples = new int[nitems ]; int i; for (i = 0; i < nitems ; i++) { int j; double rsum = 0, zsum = 0; int n = 0; for (j = 0; j < generic eggsummary < Sample > ::eggs reporting ; j ++ ) { if ( issamplevalid ( generic eggsummary < Sample > ::get egg index (i, j) ) ) { n++; rsum += generic eggsummary < Sample > ::get egg index (i, j); nsamples [i] = n; mean [i] = rsum /n; stouffer z [i] = ( mean [i] ( generic eggsummary < Sample > ::trial size /2 ) ) / ( sqrt ( generic eggsummary < Sample > ::trial size /4.0 ) / sqrt (static cast double (n)) ) ; if (isnan (stouffer z [i]) (i > 0)) { stouffer z [i] = stouffer z [i 1];
6 THE EGG ANALYSIS CLASS ANALYSIS 10 10. Slicing the data set the other way, by egg rather than time, yields statistics on the behaviour of individual eggs over the time period in the database. These statistics are largely irrelevant to hypotheses being tested by the GCP, but facilitate studies of peculiarities of individual or classes of random event generators which may influence the composite result. For each egg, we compute for all n valid samples s x : egg_num_sample n egg_mean µ = egg_stdev σ = n i=0 si n n egg_min_sample min 1 i n s i egg_max_sample max 1 i n s i i=0 (si µ)2 n 1 Class definitions 8 + template class Sample void generic egganalysis Sample :: compute per egg statistics (void) { Allocate and initialise per egg statistics tables 11 ; Compute per egg sum, maximum, and minimum values 12 ; Compute per egg mean and standard deviation 13 ; 11. We begin computation of the per-egg statistics by allocating arrays for the results, one slot per egg and initialise them appropriately for the subsequent computations. If previously allocated tables are present, they are released. Allocate and initialise per egg statistics tables 11 free per egg analysis data ( ); egg mean = new double [ generic eggsummary < Sample > :: eggs reporting ] ; egg stdev = new double [ generic eggsummary < Sample > :: eggs reporting ] ; egg min sample = new Sample [ generic eggsummary < Sample > :: eggs reporting ] ; egg max sample = new Sample [ generic eggsummary < Sample > :: eggs reporting ] ; egg num sample = new int [ generic eggsummary < Sample > :: eggs reporting ] ; / Initialise variables for per-egg statistics / int i; int nitems = generic eggsummary < Sample > :: seconds of data /generic eggsummary < Sample > ::seconds per row ; for (i = 0; i < generic eggsummary < Sample > ::eggs reporting ; i++ ) { egg mean [i] = egg stdev [i] = 0; egg min sample [i] = generic eggsummary < Sample > ::trial size + 1; egg max sample [i] = 0; egg num sample [i] = 0; This code is used in section 10.
12 ANALYSIS THE EGG ANALYSIS CLASS 7 12. Next, we make a first pass over the data, accumulating the sum (to be used later to obtain the mean value), minimum, and maximum of valid samples from that egg. Along the way, we count the number of valid samples from each egg present in the data set. Compute per egg sum, maximum, and minimum values 12 for (i = 0; i < generic eggsummary < Sample > ::eggs reporting ; i++ ) { int j; for (j = 0; j < nitems ; j ++) { Sample es = generic eggsummary < Sample > ::get egg index (j, i); if (issamplevalid (es )) { egg num sample [i]++; egg mean [i] += es ; if (es < egg min sample [i]) { egg min sample [i] = es ; if (es > egg max sample [i]) { egg max sample [i] = es ; This code is used in section 10. 13. Finally, we can compute the mean and standard deviation for each egg, the mean simply by dividing the sample sum computed in the first pass by the number of valid samples, and the standard deviation by making a second pass over the data now that the mean is known. Eggs which contributed no valid samples are ignored in this step and their mean and standard deviation set to zero. The standard deviation is also set to zero if an egg contributes only a single sample. Compute per egg mean and standard deviation 13 for (i = 0; i < generic eggsummary < Sample > :: eggs reporting ; i++ ) { int j; if (egg num sample [i] > 1) { egg mean [i] /= egg num sample [i]; for (j = 0; j < nitems ; j ++) { Sample es = generic eggsummary < Sample > ::get egg index (j, i); if (issamplevalid (es )) { egg stdev [i] += (es egg mean [i]) (es egg mean [i]); egg stdev [i] = sqrt (egg stdev [i]/(egg num sample [i] 1)); This code is used in section 10. 14. As a convenience, output routines which depend on the all-egg statistics having been computed test whether the statistics have been computed and, if not, perform this task automatically. Compute all egg statistics if not previously done 14 if (mean Λ) { compute all egg statistics ( ); This code is used in sections 16 and 18. 15. And here s the same convenience for folks interested in the per-egg statistics. Compute per egg statistics if not previously done 15 if (egg mean Λ) { compute per egg statistics ( ); This code is used in section 17.
8 THE EGG ANALYSIS CLASS ANALYSIS 16 16. This method writes a.csv file containing a time series of the all-egg statistics for the time period. Need to include a table of fields in this file once it stops changing. Class definitions 8 + template class Sample void generic egganalysis Sample :: write egg statistics CSV (string filename ){ FILE of = fopen (filename.c str ( ), "w"); double ichisum = 0, chisum = 0; int nitems = generic eggsummary < Sample > ::seconds of data /generic eggsummary < Sample > ::seconds per row ; int i, idof = 0; Compute all egg statistics if not previously done 14 ; for (i = 0; i < nitems ; i++) { double zsquare = stouffer z [i] stouffer z [i]; double xe = chisquaredistribution ::x from p k (0.99999, i + 1); chisum += zsquare ; idof ++; fprintf (of, "24,%lu,%d,%.6f,%.6f,%.6f,%d,%.6f,%.6f\n", generic eggsummary < Sample > ::start time.get time ( ) + ( i generic eggsummary < Sample > ::seconds per row ), nsamples [i], mean [i], stouffer z [i], chisum, idof, xe, (chisum xe )/xe, chisquaredistribution ::p from k x (chisum, i + 1) ) ; fclose (of ); 17. The write per egg statistics CSV method creates a.csv file containing the per-egg statistics calculated by compute per egg statistics. The statistics will be calculated automatically if they haven t already been prepared. The.csv file contains one record for each egg which contributed samples to the database, formatted as follows: 25,Egg number,number of samples,mean,max,min,stdev where 25 is the record type code, Egg number the egg number, Number of samples the number of valid samples from this egg present in the data set, Mean, Max, and Min the arithmetic mean value of all samples, and the maximum and minimum values present, and Stdev the standard deviation of the samples from the egg. Eggs whose data have been entirely discarded as invalid are not listed in the report. Class definitions 8 + template class Sample void generic egganalysis Sample :: write per egg statistics CSV (string filename ){ ofstream of (filename.c str ( )); Compute per egg statistics if not previously done 15 ; of setprecision (8); for (int i = 0; i < generic eggsummary < Sample > ::eggs reporting ; i++ ) { if (egg num sample [i] > 0) { of "25," generic eggsummary < Sample > ::egg number [i] "," egg num sample [i] "," egg mean [i] "," ((double) egg max sample [i]) "," ((double) egg min sample [i]) "," egg stdev [i] endl ; of.close ( );
18 ANALYSIS THE EGG ANALYSIS CLASS 9 18. The write deviation plot method generates, with the able assistance of GNUPLOT, a chart of the cumulative deviation the time span in the object. A comparison line to a given referenceprobability (0.05 by default) can be plotted as well. If a referenceprobability of zero is specified, no reference line is plotted. You can offset the reference probability curve with respect to the data set by specifying a referenceprobabilitystarttime for the curve; the curve is plotted starting at the first time at or after the specified moment, with this Y axis origin at the value of the all-egg deviation curve at that moment. Specifying a negative value for the referenceprobability causes the curve to be plotted below the expectation value curve. Class definitions 8 + template class Sample void generic egganalysis Sample :: write deviation plot (string filename, string charttitle, int timeinterval, int tickoffset, string x axis label, double referenceprobability, systemtime referenceprobabilitystarttime ){ ofstream gp((filename + ".gp").c str ( )), dat ((filename + ".dat").c str ( )); Compute all egg statistics if not previously done 14 ; Write GNUPLOT data table for deviation plot 19 ; / Create GNUPLOT instructions to plot data / double final p = chisquaredistribution ::p from k x (idof, chisum ); gp "set term pbm small color" endl ; Generate chart title for deviation plot 20 ; gp "set ylabel \"Cumulative Deviation" endl ; Generate label for X (time) axis of deviation plot 21 ; if (timeinterval 1) { Generate X axis tick labels for deviation plot 22 ; gp "plot \"" filename ".dat\" using 1:2 title \"Composite: " generic eggsummary < Sample > :: eggs reporting " eggs; p = " setprecision (3) (1.0 final p) "\" with lines,\\" endl ; if (referenceprobability 0) { gp " \"" filename ".dat\" using 1:3 title \"p=" referenceprobability "\" with lines,\\" endl ; gp " 0 title \"\"" endl ; string command ("gnuplot "); command += filename + ".gp ppmtogif >" + filename + ".gif"; #ifdef DEV_PLOT_DEBUG cout command endl ; #else command += " 2>/dev/null"; gp.close ( ); dat.close ( ); system (command.c str ( )); #ifndef DEV_PLOT_DEBUG / Delete the temporary files used to create the plot / remove ((filename + ".gp").c str ( )); remove ((filename + ".dat").c str ( ));
10 THE EGG ANALYSIS CLASS ANALYSIS 19 19. The GNUPLOT data file for the deviation plot consists of three columns: the time interval index (used for the x axis), the cumulative deviation, and the reference probability curve (if referenceprobability 0). Write GNUPLOT data table for deviation plot 19 double ichisum = 0, chisum = 0; int nitems = generic eggsummary < Sample > ::seconds of data /generic eggsummary < Sample > ::seconds per row ; int i, ref = 0, idof = 0; double cxebase ; bool firstref = true ; for (i = 0; i < nitems ; i++) { double zsquare = stouffer z [i] stouffer z [i]; double xe = chisquaredistribution ::x from p k (0.5, i + 1); chisum += zsquare ; idof ++; dat i " " (chisum xe ); if ( ( generic eggsummary < Sample > ::start time.get time ( ) + ( generic eggsummary < Sample > :: seconds per row i ) ) referenceprobabilitystarttime.get time ( ) ) { double xpref = chisquaredistribution :: x from p k (fabs (referenceprobability ), ref + 1); if (firstref ) { cxebase = chisum xe ; firstref = false ; dat " " (((referenceprobability < 0)? 1 : 1) ((chisquaredistribution ::x from p k (0.5, ref + 1) xpref ) + cxebase )); ref ++; dat endl ; This code is used in section 18. 20. If the user doesn t supply a custom title for the chart, generate one from the start and end times of the data plotted. If the chart covers precisely one day, the default title is just the date. If the start and end times are in the same day but not the first and last seconds of it, the date is given only before the start time. Generate chart title for deviation plot 20 if (charttitle "") { charttitle = generic eggsummary < Sample > :: start time.datetostring ( ); if ( ( generic eggsummary < Sample > ::start time.get time ( ) generic eggsummary < Sample > ::start time.midnight ( ) ) ( ( generic eggsummary < Sample > ::end time.get time ( )+1 ) ( generic eggsummary < Sample > ::start time.get time ( ) + systemtime ::SecondsPerDay ) ) ) { charttitle += " " + generic eggsummary < Sample > ::start time.timetostring ( ); charttitle += " "; if ( generic eggsummary < Sample > ::start time.midnight ( ) generic eggsummary < Sample > ::end time.midnight ( ) ) { charttitle += generic eggsummary < Sample > :: end time.datetostring ( ) + " "; charttitle += generic eggsummary < Sample > :: end time.timetostring ( ); gp "set title \"" charttitle "\"" endl ; This code is used in section 18.
21 ANALYSIS THE EGG ANALYSIS CLASS 11 21. The caller can supply the label for the x (time) axis of the deviation plot explicitly by passing the desired label as the x axis label argument (or a single blank for no label at all). If the null string is supplied (the default if the argument is omitted), a label will be generated based on the timeinterval argument. If the timeinterval is not one of the intervals defined below, the axis will be labeled as Time Periods you should provide a custom label along with a nonstandard time interval. Generate label for X (time) axis of deviation plot 21 if (x axis label " ") { if (x axis label "") { switch (timeinterval ) { case 1: x axis label = "Seconds"; break; case systemtime :: SecondsPerMinute : x axis label = "Minutes"; break; case systemtime :: SecondsPerHour : x axis label = "Hours"; break; case systemtime :: SecondsPerDay : x axis label = "Days"; break; default: x axis label = "Time Periods"; break; x axis label += " Elapsed"; gp "set xlabel \"" x axis label "\"" endl ; This code is used in section 18. 22. If the timeinterval is one second (the default), GNUPLOT s default x axis labeling is adequate. Otherwise, we must generate a set xtics statement which supplies the labels and gives their locations along the axis. We place labels at each timeinterval, offset tickoffset seconds, which may be positive or negative. Generate X axis tick labels for deviation plot 22 int ctime = generic eggsummary < Sample > ::start time.get time ( ) + tickoffset ; bool first = true ; gp "set xtics ( \\" endl ; for (i = 0; i < nitems ; i++) { if ((ctime % timeinterval ) 0) { if ( first ) { gp ",\\" endl ; first = false ; gp "\"" ((i + tickoffset )/timeinterval ) "\" " i; ctime ++; gp "\\" endl " )" endl ; This code is used in section 18.
12 TEST PROGRAM ANALYSIS 23 23. Test program. analysis_test.c 1 + Test program include files 26 ; Show how to call test program 25 ; int main (int argc, char argv [ ]){ extern char optarg ; / Imported from getopt / extern int optind ; try { int opt ; Process command-line options 24 ; #if 0 / Eggsummary analysis and plotting tests / { int j; eggdatabases ed ; ed.set Fourmilab defaults ( ); #ifndef CACHE_TEST #define DEFAULT_EGGANALYSIS #ifdef DEFAULT_EGGANALYSIS generic eggsummary cache < egganalysis > ec(&ed, "rotten_egg.csv", 50, 150); egganalysis esr ; egganalysis ext ; #else typedef generic egganalysis double double egganalysis; generic eggsummary cache < double egganalysis > ec(&ed, "rotten_egg.csv", 50, 150); double egganalysis esr ; double egganalysis ext ; esr = ec.get by date ("2001 04 22"); systemtime refstart ; / refstart.fromstring( 2001-04-22 08:00:00 ); / / refstart.fromstring( 2001-04-22 00:00:00 ); / #ifndef EXTRACT_TEST systemtime exstart, exend ; exstart.fromstring ("2001 04 22 13:00:00"); exend.fromstring ("2001 04 22 22:30:00"); esr extract time range (&ext, exstart, exend ); esr = &ext ; esr compute per egg statistics ( ); esr describe ( ); esr write per egg statistics CSV ("peregg.csv"); esr write deviation plot ("devtest", / Name of plot file / "", / Custom title for chart / systemtime :: SecondsPerHour, / Time interval for x axis labels / systemtime :: SecondsPerHour 8, / Offset in seconds for x axis labels / "", / Custom title for x axis / 0.05, / Probability for reference curve / refstart / Time to begin reference curve plot / ); #else egganalysis esr ; systemtime t; t.fromstring ("2001 04 22"); / t.fromstring( 2001-11-29 ); / esr.load from CSV (ed.database file (t)); esr.exclude bad data ("rotten_egg.csv");
23 ANALYSIS TEST PROGRAM 13 esr.limit to range (50, 150, &cout ); esr.compute all egg statistics ( ); #if 0 for (j = 0; j < esr.eggs reporting ; j ++) { cout esr.egg number [j] ": " (int) esr.get egg index (86399, j) "\n"; #if 0 esr.write egg statistics CSV ("test_24.csv"); #ifndef SIMPLE esr.write deviation plot ("devtest", / Name of plot file / "", / Earth Day: 2001 April 22, // Custom title for chart / systemtime :: SecondsPerHour, / Time interval for x axis labels / systemtime :: SecondsPerHour 8, / Offset in seconds for x axis labels / "", / Custom title for x axis / 0.05 / Probability for reference curve / ); #else esr.write deviation plot ("devtest", / Name of plot file / "Earth Day: 2001 April 22", / Custom title for chart / systemtime :: SecondsPerHour / Time interval for x axis labels / ); #if 1 / Multi-day extraction and analysis tests / { eggdatabases ed ; ed.set Fourmilab defaults ( ); generic eggsummary cache < egganalysis > ec(&ed, "rotten_egg.csv", 50, 150); egganalysis ext ; systemtime refstart ; systemtime exstart, exend ; exstart.fromstring ("2001 04 20 13:00:00"); exend.fromstring ("2001 04 24 22:30:00"); ec.extract time range (&ext, exstart, exend ); ext.compute per egg statistics ( ); ext.describe ( ); ext.write per egg statistics CSV ("peregg.csv"); ext.write deviation plot ("devtest", / Name of plot file / "", / Custom title for chart / systemtime :: SecondsPerHour, / Time interval for x axis labels / systemtime :: SecondsPerHour 8, / Offset in seconds for x axis labels / "", / Custom title for x axis / 0.05, / Probability for reference curve / refstart / Time to begin reference curve plot / ); catch(exception &e)
14 TEST PROGRAM ANALYSIS 23 { cout "Blooie!!! Exception popped: " e.what ( ) endl ; #ifndef CORE_DUMP #ifdef STACK_TRACE char s[160]; sprintf (s, "/bin/echo where\nq >/tmp/gdbcmd ; gdb batch command ""/tmp/gdbcmd %s %d", argv [0], getpid ( )); system (s); sleep(5); throw; / Re-throw exception to dump core / return 0; 24. We use getopt to process command line options. This permits aggregation of options without arguments and both darg and d arg syntax. Process command-line options 24 while ((opt = getopt (argc, argv, "nu :")) 1) { switch (opt ) { case u : / u Print how-to-call information / case? : usage ( ); return 0; case : / Extended options / switch (optarg [0]) { case c : / copyright / cout "This program is in the public domain.\n"; return 0; case h : / help / usage ( ); return 0; case v : / version / cout PRODUCT " " VERSION "\n"; cout "Last revised: " REVDATE "\n"; cout "The latest version is always available\n"; cout "at http://www.fourmilab.ch/eggtools/eggshell\n"; return 0; This code is used in section 23.
25 ANALYSIS TEST PROGRAM 15 25. Procedure usage prints how-to-call information. Show how to call test program 25 static void usage (void) { cout PRODUCT " Analyse eggsummary files. Call:\n"; cout " " PRODUCT " [options] [infile] [outfile]\n"; cout "\n"; cout "Options:\n"; cout " copyright Print copyright information\n"; cout " u, help Print this message\n"; cout " version Print version number\n"; cout "\n"; cout "by John Walker\n"; cout "http://www.fourmilab.ch/\n"; This code is used in section 23. 26. We need the following definitions to compile the test program. Test program include files 26 #include "config.h" / Our configuration / / C++ include files / #include <iostream> #include <exception> #include <stdexcept> #include <string> using namespace std; #include <stdio.h> #include <stdlib.h> #include <ctype.h> #ifdef HAVE_GETOPT #ifdef HAVE_UNISTD_H #include <unistd.h> #else #include "getopt.h" / No system getopt use our own / #include "analysis.h" / Class definitions for this package / This code is used in section 23.
16 INDEX ANALYSIS 27 27. Index. The following is a cross-reference table for analysis. Single-character identifiers are not indexed, nor are reserved words. Underlined entries indicate where an identifier was declared. ANALYSIS_HEADER_DEFINES: 3. argc: 23, 24. argv : 23, 24. assert : 9. c str : 16, 17, 18. CACHE_TEST: 23. charttitle : 8, 18, 20. chisquaredistribution : 16, 18, 19. chisum : 16, 18, 19. close : 17, 18. command : 18. compute all egg statistics : 8, 9, 14, 23. compute per egg statistics : 8, 10, 15, 17, 23. CORE_DUMP: 23. cout : 18, 23, 24, 25. ctime : 22. cxebase : 19. dat : 18, 19. database file : 23. datetostring : 20. DEFAULT_EGGANALYSIS: 23. describe : 23. DEV_PLOT_DEBUG: 18. double egganalysis: 23. e: 23. ec: 23. ed : 23. egg max sample : 8, 11, 12, 17. egg mean : 8, 11, 12, 13, 15, 17. egg min sample : 8, 11, 12, 17. egg num sample : 8, 11, 12, 13, 17. egg number : 17, 23. egg stdev : 8, 11, 13, 17. egganalysis : 8, 23. eggdatabases : 23. eggs reporting : 9, 11, 12, 13, 17, 18, 23. eggsummary : 8. end time : 20. endl : 17, 18, 19, 20, 21, 22, 23. es : 12, 13. esr : 23. exception: 23. exclude bad data : 23. exend : 23. exstart : 23. ext : 23. EXTRACT_TEST: 23. extract time range : 23. fabs : 19. false : 19, 22. fclose : 16. filename : 8, 16, 17, 18. final p: 18. first : 22. firstref : 19. fopen : 16. fprintf : 16. free all egg analysis data : 8, 9. free per egg analysis data : 8, 11. fromstring : 23. generic egganalysis: 1, 8, 9, 10, 16, 17, 18, 23. generic eggsummary : 1, 8, 9, 11, 12, 13, 16, 17, 18, 19, 20, 22. generic eggsummary cache : 23. get by date : 23. get egg index : 9, 12, 13, 23. get time : 16, 19, 20, 22. getopt : 23, 24. getpid : 23. gp: 18, 20, 21, 22. HAVE_GETOPT: 26. HAVE_UNISTD_H: 26. i: 9, 11, 16, 17, 19. ichisum : 16, 19. idof : 16, 18, 19. isnan : 9. issamplevalid : 9, 12, 13. j: 9, 12, 13, 23. limit to range : 23. load from CSV : 23. main : 23. mean : 8, 9, 14, 16. midnight : 20. n: 9. nitems : 9, 11, 12, 13, 16, 19, 22. nsamples : 8, 9, 16. of : 16, 17. ofstream: 17, 18. opt : 23, 24. optarg : 23, 24. optind : 23. p from k x : 16, 18. PRODUCT: 24, 25. ref : 19. referenceprobability : 8, 18, 19. referenceprobabilitystarttime : 8, 18, 19. refstart : 23. ReleaseTable : 8. remove : 18. REVDATE: 1, 24.
27 ANALYSIS INDEX 17 rsum : 9. s: 23. Sample: 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 22. seconds of data : 9, 11, 16, 19. seconds per row : 9, 11, 16, 19. SecondsPerDay : 20, 21. SecondsPerHour : 21, 23. SecondsPerMinute : 21. set Fourmilab defaults : 23. setprecision : 17, 18. SIMPLE: 23. sleep: 23. sprintf : 23. sqrt : 9, 13. STACK_TRACE: 23. start time : 16, 19, 20, 22. std: 3, 26. stouffer z : 8, 9, 16, 19. string: 8, 16, 17, 18. system : 18, 23. systemtime: 8, 18, 20, 21, 23. t: 23. tickoffset : 8, 18, 22. timeinterval : 8, 18, 21, 22. timetostring : 20. trial size : 9, 11. true : 19, 22. usage : 24, 25. variance : 8, 9. VERSION: 24. what : 23. write deviation plot : 8, 18, 23. write egg statistics CSV : 8, 16, 23. write per egg statistics CSV : 8, 17, 23. x axis label : 8, 18, 21. x from p k : 16, 19. xe : 16, 19. xpref : 19. zsquare : 16, 19. zsum : 9.
18 NAMES OF THE SECTIONS ANALYSIS Allocate and initialise per egg statistics tables 11 Used in section 10. Application include files 4 Used in section 2. Class definitions 8, 9, 10, 16, 17, 18 Used in section 3. Class implementations 6 Used in section 2. Compute all egg statistics if not previously done 14 Used in sections 16 and 18. Compute per egg mean and standard deviation 13 Used in section 10. Compute per egg statistics if not previously done 15 Used in section 17. Compute per egg sum, maximum, and minimum values 12 Used in section 10. Egg analysis utilities 5 Used in section 6. Generate X axis tick labels for deviation plot 22 Used in section 18. Generate chart title for deviation plot 20 Used in section 18. Generate label for X (time) axis of deviation plot 21 Used in section 18. Process command-line options 24 Used in section 23. Show how to call test program 25 Used in section 23. Test program include files 26 Used in section 23. Write GNUPLOT data table for deviation plot 19 Used in section 18. analysis.h 3 analysis_test.c 1, 23
ANALYSIS Section Introduction........................................................................ 1 1 Program global context............................................................. 2 2 Egg analysis utilities................................................................ 7 3 The Egg Analysis Class............................................................ 8 4 Test program...................................................................... 23 12 Index.............................................................................. 27 16 Page