FlowChange.FlowChangeLikely#
Baseline.FlowChangeLikely.py
- compute_yscale(x, y)#
Compute the y-scale for likelihood computation.
- Parameters:
x (array-like) – The x-values of the curve.
y (array-like) – The y-values of the curve.
- Returns:
The y-scale value.
- Return type:
- get_safeslice(lb, ub, start, stop)#
Get a safe slice within the bounds [lb, ub).
- find_nearest_point(px, py, i, x, y, yscale)#
Find the nearest point to (px, py) around index i.
- Parameters:
- Returns:
The index of the nearest point.
- Return type:
- compute_flowchange_likelihoods(x, y, points, segments, yscale=None, return_neighbours=False)#
Compute the flow change likelihoods at the given points.
- Parameters:
x (array-like) – The x-values of the curve.
y (array-like) – The y-values of the curve.
segments (list of Linesegment) – The list of line segments.
yscale (float, optional) – The y-scale for likelihood computation. If None, it will be computed from the data.
return_neighbours (bool, optional) – If True, also return the neighbouring point indices for each breakpoint. Defaults to False.
- Returns:
likelihoods (array-like) – The normalized likelihoods for each breakpoint.
neighbours (list of tuples, optional) – If return_neighbours is True, a list of (j, k) tuples where j and k are the indices of the nearest points on either side of each breakpoint.
- flowchange_likelihood(x, y, i, seg1, seg2, yscale, neighbours=None, debug=False)#
Compute the flow change likelihood at the given index.
- Parameters:
x (array-like) – The x-values of the curve.
y (array-like) – The y-values of the curve.
i (int) – The index of the breakpoint.
seg1 (Linesegment) – The segment before the breakpoint.
seg2 (Linesegment) – The segment after the breakpoint.
yscale (float) – The y-scale for likelihood computation.
neighbours (list of tuples, optional) – If provided, the function will append the (j, k) indices of the nearest points on either side of the breakpoint to this list.
debug (bool, optional) – If True, print debug information.
- Returns:
The likelihood value for the breakpoint.
- Return type: