58 float (*samples)[
D],
uint16_t count,
float *params,
float *fit_error __attribute__((unused)))
63 float errors[n_iterations];
67 float subset_params[n_iterations][D_1];
76 for (
int i = 0; i < n_iterations; i++) {
83 subset_targets[j] = targets[indices_subset[j]];
84 for (
int k = 0; k <
D; k++) {
85 subset_samples[j][k] = samples[indices_subset[j]][k];
91 printf(
"params normal: %f, %f\n", subset_params[i][0], subset_params[i][1]);
96 printf(
"params prior: %f, %f\n", subset_params[i][0], subset_params[i][1]);
101 for (
int j = 0; j < count; j++) {
103 prediction =
predict_value(samples[j], subset_params[i],
D, use_bias);
104 err = fabsf(prediction - targets[j]);
106 err = (err > error_threshold) ? error_threshold : err;
113 float min_err = errors[0];
115 for (
int i = 1; i < n_iterations; i++) {
116 if (errors[i] < min_err) {
123 for (
int d = 0; d < D_1; d++) {
124 params[d] = subset_params[min_ind][d];
141 for (
int w = 0; w <
D; w++) {
142 sum += weights[w] * sample[w];
166 bool picked_number =
false;
167 while (!picked_number) {
168 index = rand() % count;
170 for (
int k = 0; k < j; k++) {
171 if (indices_subset[k] == index) {
177 indices_subset[j] = index;
178 picked_number =
true;