-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmean_estimation.py
43 lines (30 loc) · 1.33 KB
/
mean_estimation.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
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 25 23:15:49 2023
Considering that the lambda value does not change and mapping is not easy to fin
we just take a moving average.
@author: Volkan Kumtepeli
"""
import matplotlib.pyplot as plt
import itertools
import numpy as np
from default_settings import def_settings
from aux_functions import moving_average_filter, simulate_and_save
def geo_mean_overflow(iterable): # https://stackoverflow.com/questions/43099542/python-easy-way-to-do-geometric-mean-in-python
return np.exp(np.log(iterable).mean())
settings = def_settings
settings['folderName'] = 'results/mean_window_2023_09_26'
window_length_d = [7, 15, 30, 60, 90, 180, 365] # from 7 day, 15 days, 30, 60, 90
settings['studyName'] = "mean_window"
settings['meanFunction'] = np.mean
for i, window in enumerate(window_length_d):
settings['lambda_cyc'], settings['lambda_cal'] = [0.01, 0.01]
settings['window_length_d'] = window
simulate_and_save(settings, i, simFunction=moving_average_filter)
settings['studyName'] = "geo_mean_window"
settings['meanFunction'] = geo_mean_overflow
for i, window in enumerate(window_length_d):
# if(i<5): continue
settings['lambda_cyc'], settings['lambda_cal'] = [0.01, 0.01]
settings['window_length_d'] = window
simulate_and_save(settings, i, simFunction=moving_average_filter)