-
Notifications
You must be signed in to change notification settings - Fork 9
/
recently.py
56 lines (42 loc) · 1.26 KB
/
recently.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from numba import jit
from commons import *
tf = time_factor = 0.99999985
spans = []
for i in range(11):
p = 1.5
b = -9
a = 10
spans.append([a*p**i+b if i else 0, a*p**(i+1)+b])
def avg_integrate(low, high):
return integrate(low, high) / (high-low)
def integrate(low, high, fact=tf):
'''
integrate 0.9^x from 1 to 10
'''
def antid(x):
return fact**x / math.log(fact)
return antid(high) - antid(low)
if __name__ == '__main__':
print(spans)
print(integrate(1, 10, .9))
for low,high in spans:
avgi = avg_integrate(low*86400, high*86400)
if __name__=='__main__':
print(f'{low:.4f}, {high:.4f}, {avgi:.4f}')
exponential_falloff_spans = _efs = []
for low,high in spans:
avgi = avg_integrate(low*86400, high*86400)
_efs.append((
-low*86400, # later
-high*86400, # earlier
avgi, # factor
))
def get_exponential_falloff_spans_for_now():
return [
[time_iso_now(earlier), time_iso_now(later), factor]
for i, (later, earlier, factor) in enumerate(_efs)
]
if __name__ == '__main__':
print(str(get_exponential_falloff_spans_for_now()).replace("'", '"'))
if __name__ == '__main__':
timethis('$get_exponential_falloff_spans_for_now()')