In [1]:
import numpy as np
import biogeme.hamabs as hm
In [2]:
import biogeme.messaging as msg
logger = msg.bioMessage()
#logger.setSilent()
#logger.setDetailed()
logger.setDebug()
In [3]:
s = hm.smoothing(3)
batch = 0.5
In [4]:
s.f_g_h()
Out[4]:
(None, None, None)
In [5]:
f = 3
s.add(f,None,None,batch)
Out[5]:
(3.0, None, None)
In [6]:
s.add(5,None,None,batch)
Out[6]:
(4.3559322033898304, None, None)
In [7]:
g = np.array([1,1])
h = np.array([[1,2],[3,4]])
s.add(7,g,h,batch)
Out[7]:
(5.569759896171316,
 array([1., 1.]),
 array([[1., 2.],
        [3., 4.]]))
In [8]:
print(s.f)
print(s.g)
print(s.h)
[3, 5, 7]
[None, None, array([1, 1])]
[None, None, array([[1, 2],
       [3, 4]])]
In [9]:
g = np.array([1,1])
s.add(7,g,None,batch)
Out[9]:
(6.531473069435432,
 array([1., 1.]),
 array([[1., 2.],
        [3., 4.]]))
In [10]:
s.add(5,None,None,batch)
Out[10]:
(5.961713173264115,
 array([1., 1.]),
 array([[1., 2.],
        [3., 4.]]))
In [11]:
print(s.f)
[3, 5, 7, 7, 5]
In [12]:
print(s.g)
[None, None, array([1, 1]), array([1, 1]), None]
In [13]:
print(s.h)
[None, None, array([[1, 2],
       [3, 4]]), None, None]
In [14]:
g = np.array([1,1])
s.add(7,g,None,batch)
s.add(7,g,None,batch)
s.add(7,g,None,batch)
Out[14]:
(7.0, array([1., 1.]), None)
In [15]:
print(s.f)
[3, 5, 7, 7, 5, 7, 7, 7]
In [16]:
s.add(1,g,h,batch)
s.f_g_h()
Out[16]:
(3.885139519792343,
 array([1., 1.]),
 array([[1., 2.],
        [3., 4.]]))
In [ ]: