"""
Cost Segment Structure [ex103.0]
================================
Defines a cost segment which consists of an ALSSM and a left-sided,
exponentially decaying window.
See also:
:ref:`Cost Function Classes `,
:class:`~lmlib.statespace.costfunc.CostSegment`,
:class:`~lmlib.statespace.costfunc.Segment`
"""
import numpy as np
import lmlib as lm
# Defining an second order polynomial ALSSM
alssm_poly = lm.AlssmPoly(poly_degree=2, label="alssm-polynomial")
# Defining a segment with a left-sided, exponentially decaying window
a = -np.inf # left boundary
b = -1 # right boundary
g = 50 # effective weighted number of sample under the window (controlling the window size)
left_seg = lm.Segment(a, b, lm.FORWARD, g, label="left-decaying")
# creating the cost segment, combining window (segment) and model (ALSSM).
costs = lm.CostSegment(alssm_poly, left_seg, label="costs segment for polynomial model")
# print internal structure
print(costs)