diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-11-18 19:19:10 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-11-18 19:19:10 +0100 |
commit | 8ea5327297c6dc43c9bea725ca10cd379533ae2c (patch) | |
tree | c71b7753076b8cf7323e7daca2932ef8a1244715 /src/rps/rps-sampler_client.c | |
parent | 75f764ad21fd850bd068f5746b8db89d49e784d1 (diff) | |
parent | 52968789d280ee066e4527d6b191691625bd993a (diff) | |
download | gnunet-8ea5327297c6dc43c9bea725ca10cd379533ae2c.tar.gz gnunet-8ea5327297c6dc43c9bea725ca10cd379533ae2c.zip |
Merge branch 'master' of git+ssh://gnunet.org/gnunet
Diffstat (limited to 'src/rps/rps-sampler_client.c')
-rw-r--r-- | src/rps/rps-sampler_client.c | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c index 5ab854e01..f6e98ce29 100644 --- a/src/rps/rps-sampler_client.c +++ b/src/rps/rps-sampler_client.c | |||
@@ -258,39 +258,39 @@ RPS_sampler_mod_init (size_t init_size, | |||
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | /** | 261 | // /** |
262 | * @brief Compute the probability that we already observed all peers from a | 262 | // * @brief Compute the probability that we already observed all peers from a |
263 | * biased stream of peer ids. | 263 | // * biased stream of peer ids. |
264 | * | 264 | // * |
265 | * Deficiency factor: | 265 | // * Deficiency factor: |
266 | * As introduced by Brahms: Factor between the number of unique ids in a | 266 | // * As introduced by Brahms: Factor between the number of unique ids in a |
267 | * truly random stream and number of unique ids in the gossip stream. | 267 | // * truly random stream and number of unique ids in the gossip stream. |
268 | * | 268 | // * |
269 | * @param num_peers_estim The estimated number of peers in the network | 269 | // * @param num_peers_estim The estimated number of peers in the network |
270 | * @param num_peers_observed The number of peers the given element has observed | 270 | // * @param num_peers_observed The number of peers the given element has observed |
271 | * @param deficiency_factor A factor that catches the 'bias' of a random stream | 271 | // * @param deficiency_factor A factor that catches the 'bias' of a random stream |
272 | * of peer ids | 272 | // * of peer ids |
273 | * | 273 | // * |
274 | * @return The estimated probability | 274 | // * @return The estimated probability |
275 | */ | 275 | // */ |
276 | static double | 276 | // static double |
277 | prob_observed_n_peers (uint32_t num_peers_estim, | 277 | // prob_observed_n_peers (uint32_t num_peers_estim, |
278 | uint32_t num_peers_observed, | 278 | // uint32_t num_peers_observed, |
279 | double deficiency_factor) | 279 | // double deficiency_factor) |
280 | { | 280 | // { |
281 | uint32_t num_peers = num_peers_estim * (1 / deficiency_factor); | 281 | // uint32_t num_peers = num_peers_estim * (1 / deficiency_factor); |
282 | uint64_t sum = 0; | 282 | // uint64_t sum = 0; |
283 | 283 | // | |
284 | for (uint32_t i = 0; i < num_peers; i++) | 284 | // for (uint32_t i = 0; i < num_peers; i++) |
285 | { | 285 | // { |
286 | uint64_t a = pow (-1, num_peers - i); | 286 | // uint64_t a = pow (-1, num_peers - i); |
287 | uint64_t b = binom (num_peers, i); | 287 | // uint64_t b = binom (num_peers, i); |
288 | uint64_t c = pow (i, num_peers_observed); | 288 | // uint64_t c = pow (i, num_peers_observed); |
289 | sum += a * b * c; | 289 | // sum += a * b * c; |
290 | } | 290 | // } |
291 | 291 | // | |
292 | return sum / (double) pow (num_peers, num_peers_observed); | 292 | // return sum / (double) pow (num_peers, num_peers_observed); |
293 | } | 293 | // } |
294 | 294 | ||
295 | 295 | ||
296 | /** | 296 | /** |
@@ -379,7 +379,8 @@ sampler_mod_get_rand_peer (void *cls) | |||
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | /* compute probability */ | 381 | /* compute probability */ |
382 | /* Currently disabled due to numerical limitations */ | 382 | /* FIXME: Currently disabled due to numerical limitations */ |
383 | prob_observed_n = 0; // Inititialise to some value | ||
383 | // prob_observed_n = prob_observed_n_peers (sampler->num_peers_estim, | 384 | // prob_observed_n = prob_observed_n_peers (sampler->num_peers_estim, |
384 | // s_elem->num_peers, | 385 | // s_elem->num_peers, |
385 | // sampler->deficiency_factor); | 386 | // sampler->deficiency_factor); |