Add support for more than two datasets. Currently limited to 7 though

the limit is only the number of meaningful graph symbols available.

Statistical comparison is performed between the first dataset and
any further datasets.

No objection by:	 phk
This commit is contained in:
Matthew N. Dodd 2005-04-13 05:50:56 +00:00
parent 014fbb87b8
commit afe98543b8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144993
2 changed files with 58 additions and 58 deletions

View file

@ -126,6 +126,9 @@ double student [NSTUDENT + 1][NCONF] = {
/* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 } /* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 }
}; };
#define MAX_DS 8
static char symbol[MAX_DS] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' };
TAILQ_HEAD(pointlist, point); TAILQ_HEAD(pointlist, point);
struct dataset { struct dataset {
@ -234,8 +237,7 @@ Vitals(struct dataset *ds, int flag)
{ {
double a; double a;
printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", symbol[flag],
flag == 1 ? 'x' : '+',
ds->n, Min(ds), Max(ds), Median(ds), Avg(ds), Stddev(ds)); ds->n, Min(ds), Max(ds), Median(ds), Avg(ds), Stddev(ds));
printf("\n"); printf("\n");
} }
@ -416,14 +418,10 @@ DumpPlot(void)
putchar('|'); putchar('|');
for (j = 0; j < pl->width; j++) { for (j = 0; j < pl->width; j++) {
k = pl->data[(pl->height - i) * pl->width + j]; k = pl->data[(pl->height - i) * pl->width + j];
switch (k) { if (k >= 0 && k < MAX_DS)
case 0: putchar(' '); break; putchar(symbol[k]);
case 1: putchar('x'); break; else
case 2: putchar('+'); break; printf("[%02x]", k);
case 3: putchar('*'); break;
default: printf("[%02x]", k); break;
}
} }
putchar('|'); putchar('|');
putchar('\n'); putchar('\n');
@ -503,7 +501,7 @@ usage(char const *whine)
fprintf(stderr, "%s\n", whine); fprintf(stderr, "%s\n", whine);
fprintf(stderr, fprintf(stderr,
"Usage: ministat [ -c confidence ] [-s] [file 1 [file 2]]\n"); "Usage: ministat [ -c confidence ] [-s] [file [file ...]]\n");
fprintf(stderr, "\tconfidence = {"); fprintf(stderr, "\tconfidence = {");
for (i = 0; i < NCONF; i++) { for (i = 0; i < NCONF; i++) {
fprintf(stderr, "%s%g%%", fprintf(stderr, "%s%g%%",
@ -518,7 +516,8 @@ usage(char const *whine)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct dataset *ds1, *ds2, *ds3; struct dataset *ds[7];
int nds;
double a; double a;
char *p; char *p;
int c, i, ci; int c, i, ci;
@ -550,29 +549,30 @@ main(int argc, char **argv)
argv += optind; argv += optind;
if (argc == 0) { if (argc == 0) {
ds1 = ReadSet(NULL); ds[0] = ReadSet(NULL);
printf("x stdin\n"); printf("x stdin\n");
} else if (argc > 0) { nds = 1;
ds1 = ReadSet(argv[0]); } else {
printf("x %s\n", argv[0]); if (argc > (MAX_DS - 1))
} if (argc > 1) { usage("Too many datasets.");
ds2 = ReadSet(argv[1]); nds = argc;
printf("+ %s\n", argv[1]); for (i = 0; i < nds; i++) {
ds[i] = ReadSet(argv[i]);
printf("%c %s\n", symbol[i+1], argv[i]);
}
} }
SetupPlot(74, flag_s); SetupPlot(74, flag_s);
DimPlot(ds1); for (i = 0; i < nds; i++)
if (argc > 1) DimPlot(ds[i]);
DimPlot(ds2); for (i = 0; i < nds; i++)
PlotSet(ds1, 1); PlotSet(ds[i], i + 1);
if (argc > 1)
PlotSet(ds2, 2);
DumpPlot(); DumpPlot();
VitalsHead(); VitalsHead();
Vitals(ds1, 1); Vitals(ds[0], 1);
if (argc > 1) { for (i = 1; i < nds; i++) {
Vitals(ds2, 2); Vitals(ds[i], i + 1);
Relative(ds2, ds1, ci); Relative(ds[i], ds[0], ci);
} }
exit(0); exit(0);
} }

View file

@ -126,6 +126,9 @@ double student [NSTUDENT + 1][NCONF] = {
/* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 } /* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 }
}; };
#define MAX_DS 8
static char symbol[MAX_DS] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' };
TAILQ_HEAD(pointlist, point); TAILQ_HEAD(pointlist, point);
struct dataset { struct dataset {
@ -234,8 +237,7 @@ Vitals(struct dataset *ds, int flag)
{ {
double a; double a;
printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", symbol[flag],
flag == 1 ? 'x' : '+',
ds->n, Min(ds), Max(ds), Median(ds), Avg(ds), Stddev(ds)); ds->n, Min(ds), Max(ds), Median(ds), Avg(ds), Stddev(ds));
printf("\n"); printf("\n");
} }
@ -416,14 +418,10 @@ DumpPlot(void)
putchar('|'); putchar('|');
for (j = 0; j < pl->width; j++) { for (j = 0; j < pl->width; j++) {
k = pl->data[(pl->height - i) * pl->width + j]; k = pl->data[(pl->height - i) * pl->width + j];
switch (k) { if (k >= 0 && k < MAX_DS)
case 0: putchar(' '); break; putchar(symbol[k]);
case 1: putchar('x'); break; else
case 2: putchar('+'); break; printf("[%02x]", k);
case 3: putchar('*'); break;
default: printf("[%02x]", k); break;
}
} }
putchar('|'); putchar('|');
putchar('\n'); putchar('\n');
@ -503,7 +501,7 @@ usage(char const *whine)
fprintf(stderr, "%s\n", whine); fprintf(stderr, "%s\n", whine);
fprintf(stderr, fprintf(stderr,
"Usage: ministat [ -c confidence ] [-s] [file 1 [file 2]]\n"); "Usage: ministat [ -c confidence ] [-s] [file [file ...]]\n");
fprintf(stderr, "\tconfidence = {"); fprintf(stderr, "\tconfidence = {");
for (i = 0; i < NCONF; i++) { for (i = 0; i < NCONF; i++) {
fprintf(stderr, "%s%g%%", fprintf(stderr, "%s%g%%",
@ -518,7 +516,8 @@ usage(char const *whine)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct dataset *ds1, *ds2, *ds3; struct dataset *ds[7];
int nds;
double a; double a;
char *p; char *p;
int c, i, ci; int c, i, ci;
@ -550,29 +549,30 @@ main(int argc, char **argv)
argv += optind; argv += optind;
if (argc == 0) { if (argc == 0) {
ds1 = ReadSet(NULL); ds[0] = ReadSet(NULL);
printf("x stdin\n"); printf("x stdin\n");
} else if (argc > 0) { nds = 1;
ds1 = ReadSet(argv[0]); } else {
printf("x %s\n", argv[0]); if (argc > (MAX_DS - 1))
} if (argc > 1) { usage("Too many datasets.");
ds2 = ReadSet(argv[1]); nds = argc;
printf("+ %s\n", argv[1]); for (i = 0; i < nds; i++) {
ds[i] = ReadSet(argv[i]);
printf("%c %s\n", symbol[i+1], argv[i]);
}
} }
SetupPlot(74, flag_s); SetupPlot(74, flag_s);
DimPlot(ds1); for (i = 0; i < nds; i++)
if (argc > 1) DimPlot(ds[i]);
DimPlot(ds2); for (i = 0; i < nds; i++)
PlotSet(ds1, 1); PlotSet(ds[i], i + 1);
if (argc > 1)
PlotSet(ds2, 2);
DumpPlot(); DumpPlot();
VitalsHead(); VitalsHead();
Vitals(ds1, 1); Vitals(ds[0], 1);
if (argc > 1) { for (i = 1; i < nds; i++) {
Vitals(ds2, 2); Vitals(ds[i], i + 1);
Relative(ds2, ds1, ci); Relative(ds[i], ds[0], ci);
} }
exit(0); exit(0);
} }