From: Tim Beale Date: Mon, 15 Oct 2018 21:57:29 +0000 (+1300) Subject: traffic_replay: Change user distribution to use Pareto Distribution X-Git-Tag: tdb-1.3.17~939 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdd75407afdde4db6177a981c2d91f2b113e2a19;p=thirdparty%2Fsamba.git traffic_replay: Change user distribution to use Pareto Distribution The current probability we were assigning to users roughly approximates the Pareto Distribution (with shape=1.0). This means the code now uses a documented algorithm (i.e. explanation on Wikipedia). It also allows us to vary the distribution by changing the shape parameter. Signed-off-by: Tim Beale Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index 8eb10ee8819..16672286cd8 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -1842,11 +1842,12 @@ class GroupAssignments(object): def generate_user_distribution(self, n): """Probability distribution of a user belonging to a group. """ - # Assign a weighted probability to each user. Probability decreases - # as the user-ID increases + # Assign a weighted probability to each user. Use the Pareto + # Distribution so that some users are in a lot of groups, and the + # bulk of users are in only a few groups weights = [] for x in range(1, n + 1): - p = 1 / (x + 0.001) + p = random.paretovariate(1.0) weights.append(p) # convert the weights to a cumulative distribution between 0.0 and 1.0