diff options
author | Julius Bünger <buenger@mytum.de> | 2018-04-09 20:43:17 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-04-09 20:43:17 +0200 |
commit | 9d7a72525b8a08f16d1c711fc6cbd267bb5ee9ee (patch) | |
tree | 5fe27e22bcd163af7ce73dbfaf983e957cd04e5f /src/rps/test_rps.c | |
parent | db67f7e2f62e38ee9b7cf5526609431a04f9bc9d (diff) | |
download | gnunet-9d7a72525b8a08f16d1c711fc6cbd267bb5ee9ee.tar.gz gnunet-9d7a72525b8a08f16d1c711fc6cbd267bb5ee9ee.zip |
rps profiler: improve computation of sampling probability
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index b46fc0c1e..2b5e4a8c3 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -1870,7 +1870,10 @@ static uint32_t fac (uint32_t x) | |||
1870 | 1870 | ||
1871 | static uint32_t binom (uint32_t n, uint32_t k) | 1871 | static uint32_t binom (uint32_t n, uint32_t k) |
1872 | { | 1872 | { |
1873 | GNUNET_assert (n >= k); | 1873 | //GNUNET_assert (n >= k); |
1874 | if (k > n) return 0; | ||
1875 | if (0 > n) return 0; | ||
1876 | if (0 > k) return 0; | ||
1874 | if (0 == k) return 1; | 1877 | if (0 == k) return 1; |
1875 | return fac (n) | 1878 | return fac (n) |
1876 | / | 1879 | / |
@@ -1984,11 +1987,13 @@ static void compute_probabilities (uint32_t peer_idx) | |||
1984 | prob_push = 0; | 1987 | prob_push = 0; |
1985 | } | 1988 | } |
1986 | /* 2. Probability of peer i being contained in pulls */ | 1989 | /* 2. Probability of peer i being contained in pulls */ |
1987 | // FIXME this computation is not yet correct | ||
1988 | view_size = rps_peers[peer_idx].cur_view_count; | 1990 | view_size = rps_peers[peer_idx].cur_view_count; |
1989 | cont_views = count_containing_views (i, peer_idx); | 1991 | cont_views = count_containing_views (i, peer_idx); |
1990 | prob_pull = 1.0 - | 1992 | prob_pull = 1.0 |
1991 | (1.0 / binom (view_size, 0.45 * view_size)); | 1993 | / |
1994 | (binom (view_size, 0.45 * view_size) - | ||
1995 | binom (view_size - cont_views, 0.45 * view_size)); | ||
1996 | if (0 == cont_views) prob_pull = 0; | ||
1992 | probs[i] = prob_push + prob_pull - (prob_push * prob_pull); | 1997 | probs[i] = prob_push + prob_pull - (prob_push * prob_pull); |
1993 | 1998 | ||
1994 | if (0 != probs[i]) count_non_zero_prob++; | 1999 | if (0 != probs[i]) count_non_zero_prob++; |