Skip to content

Commit

Permalink
Per #2882, update the aggregated seeps computation to use better-init…
Browse files Browse the repository at this point in the history
…ialized vectors.
  • Loading branch information
JohnHalleyGotway committed Oct 7, 2024
1 parent 710e9f6 commit 0d29a87
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/libcode/vx_statistics/compute_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1461,10 +1461,6 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps_agg)
seeps_mprs.push_back(seeps_mpr);
}
if (count > 0) {
vector<double> density_vector;
double pvf[SEEPS_MATRIX_SIZE];
double svf[SEEPS_MATRIX_SIZE];
double score_sum_wgt, weight_sum, weight[count];

mlog << Debug(9) << method_name
<< "Categories c_odfl, c_odfh, c_olfd, c_olfh, c_ohfd, c_ohfl => "
Expand All @@ -1483,27 +1479,29 @@ void compute_aggregated_seeps(const PairDataPoint *pd, SeepsAggScore *seeps_agg)
<< seeps_agg->mean_obs << " "
<< seeps_agg->score << "\n";

score_sum_wgt = 0.;
for (int i=0; i<SEEPS_MATRIX_SIZE; i++) pvf[i] = 0.;
double score_sum_wgt = 0.0;
vector<double> pvf(SEEPS_MATRIX_SIZE, 0.0);
vector<double> svf(SEEPS_MATRIX_SIZE, 0.0);

vector<double> density_vector;
compute_seeps_density_vector(pd, seeps_agg, density_vector);
int density_cnt = density_vector.size();
if(density_cnt > count) density_cnt = count;

//IDL: w = 1/d
weight_sum = 0.;
for (int i=0; i<count; i++) weight[i] = 0;
double weight_sum = 0.0;
vector<double> weight(count, 0.0);
for (int i=0; i<density_cnt; i++) {
if (!is_eq(density_vector[i], 0)) {
weight[i] = 1 / density_vector[i];
if (!is_eq(density_vector[i], 0.0)) {
weight[i] = 1.0 / density_vector[i];
weight_sum += weight[i];
mlog << Debug(9) << method_name
<< "i, dens_vec(i), weight(i), weight_sum => "
<< i << " " << density_vector[i] << " "
<< weight[i] << " " << weight_sum << "\n";
}
}
if (!is_eq(weight_sum, 0)) {
if (!is_eq(weight_sum, 0.0)) {
//IDL: w = w/sum(w)
for (int i=0; i<count; i++) weight[i] /= weight_sum;

Expand Down

0 comments on commit 0d29a87

Please sign in to comment.