summaryrefslogtreecommitdiff
path: root/monkey/util.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-02-08 05:11:30 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:02 +0200
commitb85a6499d21beec2cb87830e63e6afef9569df1a (patch)
tree4486f48751f8144e25adb162bd366dcdf3839830 /monkey/util.py
parent25dfa090db39040a93e8186d228f70f0e0bd5f23 (diff)
Simplify get_edits_from_traces
Diffstat (limited to 'monkey/util.py')
-rw-r--r--monkey/util.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/monkey/util.py b/monkey/util.py
index 6d57d29..9648926 100644
--- a/monkey/util.py
+++ b/monkey/util.py
@@ -2,6 +2,7 @@
from heapq import heappush, heappop
import itertools
+import math
# A simple priority queue based on the heapq class.
class PQueue(object):
@@ -52,3 +53,11 @@ def get_line(text, n):
# Indent each line in [text] by [indent] spaces.
def indent(text, indent=2):
return '\n'.join([' '*indent+line for line in text.split('\n')])
+
+# Average in a list.
+def avg(l):
+ return sum(l)/len(l)
+
+# Logistic function.
+def logistic(x, L=1, k=1, x_0=0):
+ return L/(1+math.exp(-k*(x-x_0)))