Mercurial Hosting > traffic-intelligence
diff python/utils.py @ 434:9a714f32fc9f
small updates
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sat, 30 Nov 2013 18:03:35 -0500 |
parents | d40ad901b272 |
children | abe0b2347d4c |
line wrap: on
line diff
--- a/python/utils.py Fri Nov 29 02:38:41 2013 -0500 +++ b/python/utils.py Sat Nov 30 18:03:35 2013 -0500 @@ -195,6 +195,12 @@ else: return 0. +def triangular(center, x, halfwidth): + diff = abs(center-x) + if diff<halfwidth: + return 1.-abs(diff/halfwidth) + else: + return 0. def argMaxDict(d): return max(d.iterkeys(), key=(lambda key: d[key]))