summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2019-04-10 14:07:28 +0200
committerJulius Bünger <buenger@mytum.de>2019-04-10 14:07:28 +0200
commit20714e46c74f47d0ecc2359cbb4aa944ecc78135 (patch)
treec773812d5bd5b9a54500a2eeb99657636fd15a2c /src
parent6e626937fd5133188d2bd06f280a1b889219eef2 (diff)
RPS profiler: Normalise correctly
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-rps-profiler.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index a13ee4078..474a83768 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -2232,7 +2232,7 @@ static void compute_probabilities (uint32_t peer_idx)
uint32_t cont_views;
uint32_t number_of_being_in_pull_events;
int tmp;
- uint32_t count_non_zero_prob = 0;
+ uint32_t sum_non_zero_prob = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Computing probabilities for peer %" PRIu32 "\n", peer_idx);
@@ -2315,21 +2315,14 @@ static void compute_probabilities (uint32_t peer_idx)
i,
number_of_being_in_pull_events);
- if (0 != probs[i]) count_non_zero_prob++;
+ sum_non_zero_prob += probs[i];
}
/* normalize */
- if (0 != count_non_zero_prob)
+ for (i = 0; i < num_peers; i++)
{
- for (i = 0; i < num_peers; i++)
- {
- probs[i] = probs[i] * (1.0 / count_non_zero_prob);
- }
- } else {
- for (i = 0; i < num_peers; i++)
- {
- probs[i] = 0;
- }
+ probs[i] = probs[i] * (1.0 / sum_non_zero_prob);
}
+
/* str repr */
for (i = 0; i < num_peers; i++)
{