tweak 90% histogram display
- also show bar - fix padding
This commit is contained in:
parent
d2db239a1d
commit
9917941048
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -364,7 +364,7 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins)
|
||||||
max_bin_count = bins[i];
|
max_bin_count = bins[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int MAX_WIDTH = 50; // Adjust this to your terminal width
|
const int MAX_WIDTH = 40; // Adjust this to your terminal width
|
||||||
double scale = max_bin_count > MAX_WIDTH ? (double)MAX_WIDTH / max_bin_count : 1.0;
|
double scale = max_bin_count > MAX_WIDTH ? (double)MAX_WIDTH / max_bin_count : 1.0;
|
||||||
|
|
||||||
// Print the histogram
|
// Print the histogram
|
||||||
|
@ -374,7 +374,12 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins)
|
||||||
decimalPlaces = -magnitude;
|
decimalPlaces = -magnitude;
|
||||||
decimalPlaces = decimalPlaces > 10 ? 10 : decimalPlaces;
|
decimalPlaces = decimalPlaces > 10 ? 10 : decimalPlaces;
|
||||||
}
|
}
|
||||||
printf("(-∞, %*.*f): %d\n", 4 + decimalPlaces, decimalPlaces, min_value, below_min);
|
printf("(%*s, %*.*f): ", 6 + decimalPlaces, "-∞", 4 + decimalPlaces, decimalPlaces, min_value);
|
||||||
|
int marks_below_min = (int)(below_min * scale);
|
||||||
|
for (int j = 0; j < marks_below_min; j++) {
|
||||||
|
printf("█");
|
||||||
|
}
|
||||||
|
printf(" %d\n", below_min);
|
||||||
for (int i = 0; i < n_bins; i++) {
|
for (int i = 0; i < n_bins; i++) {
|
||||||
double bin_start = min_value + i * bin_width;
|
double bin_start = min_value + i * bin_width;
|
||||||
double bin_end = bin_start + bin_width;
|
double bin_end = bin_start + bin_width;
|
||||||
|
@ -392,7 +397,12 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins)
|
||||||
}
|
}
|
||||||
printf(" %d\n", bins[i]);
|
printf(" %d\n", bins[i]);
|
||||||
}
|
}
|
||||||
printf("(%*.*f, +∞): %d\n", 4 + decimalPlaces, decimalPlaces, max_value, above_max);
|
printf("(%*.*f, %*s): ", 4 + decimalPlaces, decimalPlaces, min_value, 6 + decimalPlaces, "+∞");
|
||||||
|
int marks_above_max = (int)(above_max * scale);
|
||||||
|
for (int j = 0; j < marks_above_max; j++) {
|
||||||
|
printf("█");
|
||||||
|
}
|
||||||
|
printf(" %d\n", above_max);
|
||||||
|
|
||||||
// Free the allocated memory for bins
|
// Free the allocated memory for bins
|
||||||
free(bins);
|
free(bins);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user