Compare commits
3 Commits
2744136d68
...
1e061095d9
Author | SHA1 | Date | |
---|---|---|---|
1e061095d9 | |||
e971d6e1e2 | |||
3e2eb69e3a |
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.
Binary file not shown.
|
@ -334,8 +334,13 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins){
|
||||||
double bin_width = range / n_bins;
|
double bin_width = range / n_bins;
|
||||||
|
|
||||||
// Fill the bins with sample counts
|
// Fill the bins with sample counts
|
||||||
|
int below_min = 0, above_max = 0;
|
||||||
for (int i = 0; i < n_samples; i++) {
|
for (int i = 0; i < n_samples; i++) {
|
||||||
if((x[i] > min_value) && (x[i] < max_value)){
|
if(xs[i] < min_value){
|
||||||
|
below_min++;
|
||||||
|
}else if (xs[i] > max_value){
|
||||||
|
above_max++;
|
||||||
|
}else{
|
||||||
int bin_index = (int)((xs[i] - min_value) / bin_width);
|
int bin_index = (int)((xs[i] - min_value) / bin_width);
|
||||||
if (bin_index == n_bins) {
|
if (bin_index == n_bins) {
|
||||||
bin_index--; // Last bin includes max_value
|
bin_index--; // Last bin includes max_value
|
||||||
|
@ -355,16 +360,17 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins){
|
||||||
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
|
||||||
|
int decimalPlaces = 1;
|
||||||
|
if((0 < bin_width) && (bin_width < 1)){
|
||||||
|
int magnitude = (int) floor(log10(bin_width));
|
||||||
|
decimalPlaces = -magnitude;
|
||||||
|
decimalPlaces = decimalPlaces > 10 ? 10 : decimalPlaces;
|
||||||
|
}
|
||||||
|
printf( " (-∞, %*.*f): %d\n", 4+decimalPlaces, decimalPlaces, min_value, 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;
|
||||||
|
|
||||||
int decimalPlaces = 1;
|
|
||||||
if((0 < bin_width) && (bin_width < 1)){
|
|
||||||
int magnitude = (int) floor(log10(bin_width));
|
|
||||||
decimalPlaces = -magnitude;
|
|
||||||
decimalPlaces = decimalPlaces > 10 ? 10 : decimalPlaces;
|
|
||||||
}
|
|
||||||
printf(" [%*.*f, %*.*f", 4+decimalPlaces, decimalPlaces, bin_start, 4+decimalPlaces, decimalPlaces, bin_end);
|
printf(" [%*.*f, %*.*f", 4+decimalPlaces, decimalPlaces, bin_start, 4+decimalPlaces, decimalPlaces, bin_end);
|
||||||
char interval_delimiter = ')';
|
char interval_delimiter = ')';
|
||||||
if(i == (n_bins-1)){
|
if(i == (n_bins-1)){
|
||||||
|
@ -378,6 +384,7 @@ 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);
|
||||||
|
|
||||||
// Free the allocated memory for bins
|
// Free the allocated memory for bins
|
||||||
free(bins);
|
free(bins);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user