Trajectory
¶
Static utility class for evaluating ALSSM output trajectories.
Provides methods to compute the signal trajectories implied by a set of state vectors together with a cost's ALSSMs and segment windows, and to map those trajectories onto a common output array indexed by signal position.
Methods:
-
eval–Evaluate ALSSM output trajectories for a set of state vectors.
-
eval_y–Evaluate trajectories at anchor positions
ksand map them into a
Methods¶
eval
staticmethod
¶
Evaluate ALSSM output trajectories for a set of state vectors.
For each state vector in xs and each cost segment in cost,
computes the ALSSM output over the segment's window range.
Parameters:
-
cost(CostSegment or CompositeCost) –Cost whose ALSSM models and segments define the trajectory.
-
xs(array_like of shape (..., N)) –State vectors defining the trajectories. The last dimension must equal the ALSSM model order N.
-
F(array_like of shape (M, P) or None, default:None) –Override mapping matrix. If
None, uses the mapping defined incost. Default: None. -
thd(float, default:1e-06) –Threshold for truncating the window range at infinite segment boundaries. Default: 1e-6.
-
merged_ks(bool, default:True) –If True, merge across the state-vector dimension by taking the element-wise maximum. Default: True.
-
merged_seg(bool, default:True) –If True, merge across segments by taking the element-wise maximum. Default: True.
Returns:
-
out(ndarray of dtype=object, shape depends on merging flags) –Array of
(ab_range, trajectory)tuples. When neither flag is set, shape is(P, *XS)wherePis the number of segments andXSis the leading shape ofxs. Each tuple contains:ab_range— 1-D integer array of relative sample indices.trajectory— ALSSM output values at those indices.
Source code in lmlib/statespace/trajectory.py
eval_y
staticmethod
¶
eval_y(cost, xs, ks, K, F=None, thd=1e-06, merged_ks=True, merged_seg=True, fill_value=nan)
Evaluate trajectories at anchor positions ks and map them into a
length-K output array.
For each anchor index k in ks and each segment in cost,
evaluates the ALSSM trajectory and places the values at the absolute
signal positions k + ab_range. Out-of-bounds positions are
silently discarded.
Parameters:
-
cost(CostSegment or CompositeCost) –Cost whose ALSSM models and segments define the trajectories.
-
xs(array_like of shape (len(ks), N) or (K, N)) –State vectors. Either one state vector per anchor (shape
(len(ks), N)) or one per signal sample (shape(K, N)), in which case the state at each anchor is looked up by index. -
ks(array_like of int, shape (XS,)) –Anchor positions (absolute signal indices) at which the trajectories are centred.
-
K(int) –Length of the output signal vector.
-
F(array_like of shape (M, P) or None, default:None) –Override mapping matrix. Default: None (use cost's own mapping).
-
thd(float, default:1e-06) –Threshold for truncating the window at infinite boundaries. Default: 1e-6.
-
merged_ks(bool, default:True) –If True, merge across anchor positions using the element-wise maximum. Default: True.
-
merged_seg(bool, default:True) –If True, merge across segments using the element-wise maximum. Default: True.
-
fill_value(scalar, default:nan) –Value used for output positions not covered by any trajectory. Default:
np.nan.
Returns:
-
out(ndarray) –Mapped trajectory array of shape
(K,)after both merges,(P, K)after only theksmerge, or(P, len(ks), K)with no merging.
Notes
If ks is empty, a warning is printed and an array of shape
(K,) filled with fill_value is returned.
Raises:
-
ValueError–If
len(xs)matches neitherlen(ks)norK. -
NotImplementedError–If
costis anNDCompositeCost.
Source code in lmlib/statespace/trajectory.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |