forked from personal/squiggle.c
look through histogram function to convince myself of correctness
This commit is contained in:
parent
ab97e6ce3e
commit
19367b04cd
|
@ -242,9 +242,8 @@ void array_print_histogram(double* xs, int n_samples, int n_bins) {
|
|||
return;
|
||||
}
|
||||
|
||||
double min_value = xs[0], max_value = xs[0];
|
||||
|
||||
// Find the minimum and maximum values from the samples
|
||||
double min_value = xs[0], max_value = xs[0];
|
||||
for (int i = 0; i < n_samples; i++) {
|
||||
if (xs[i] < min_value) {
|
||||
min_value = xs[i];
|
||||
|
@ -260,8 +259,7 @@ void array_print_histogram(double* xs, int n_samples, int n_bins) {
|
|||
}
|
||||
|
||||
// Calculate bin width
|
||||
double range = max_value - min_value;
|
||||
double bin_width = range / n_bins;
|
||||
double bin_width = (max_value - min_value) / n_bins;
|
||||
|
||||
// Fill the bins with sample counts
|
||||
for (int i = 0; i < n_samples; i++) {
|
||||
|
@ -339,10 +337,7 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins){
|
|||
if (min_value == max_value) {
|
||||
max_value++;
|
||||
}
|
||||
|
||||
// Calculate bin width
|
||||
double range = max_value - min_value;
|
||||
double bin_width = range / n_bins;
|
||||
double bin_width = (max_value - min_value) / n_bins;
|
||||
|
||||
// Fill the bins with sample counts
|
||||
int below_min = 0, above_max = 0;
|
||||
|
@ -399,7 +394,6 @@ void array_print_90_ci_histogram(double* xs, int n_samples, int n_bins){
|
|||
|
||||
// Free the allocated memory for bins
|
||||
free(bins);
|
||||
|
||||
}
|
||||
|
||||
/* Algebra manipulations */
|
||||
|
|
Loading…
Reference in New Issue
Block a user