[CalendarServer-changes] [15330] CalendarServer/trunk/contrib/performance/stats.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 18 12:53:16 PST 2015


Revision: 15330
          http://trac.calendarserver.org//changeset/15330
Author:   cdaboo at apple.com
Date:     2015-11-18 12:53:16 -0800 (Wed, 18 Nov 2015)
Log Message:
-----------
Use matplotlib to visualize a LogNormal distribution.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/stats.py

Modified: CalendarServer/trunk/contrib/performance/stats.py
===================================================================
--- CalendarServer/trunk/contrib/performance/stats.py	2015-11-18 18:41:32 UTC (rev 15329)
+++ CalendarServer/trunk/contrib/performance/stats.py	2015-11-18 20:53:16 UTC (rev 15330)
@@ -473,15 +473,14 @@
 
 if __name__ == '__main__':
 
+    import matplotlib.pyplot as plt
     from collections import defaultdict
-    mu = 1.5
-    sigma = 1.22
-    distribution = LogNormalDistribution(mu, sigma, 100)
+    mode = 6.0
+    median = 8.0
+    distribution = LogNormalDistribution(mode=mode, median=median, maximum=60)
     result = defaultdict(int)
-    for i in range(100000):
+    for i in range(1000000):
         s = int(distribution.sample())
-        if s > 300:
-            continue
         result[s] += 1
 
     total = 0
@@ -490,3 +489,9 @@
         total += k * v
 
     print("Average: %.2f" % (float(total) / sum(result.values()),))
+
+    x, y = zip(*sorted(result.items()))
+    plt.plot(x, y)
+    plt.xlabel("Samples")
+    plt.ylabel("LogNormal")
+    plt.show()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151118/5574aa0a/attachment.html>


More information about the calendarserver-changes mailing list