# staircase.limit#

staircase.limit(collection, x, side='right')#

Takes a collection of Stairs instances and evaluates their limits across a set of points.

Technically the results of this function should be considered as $$\lim_{x \to z^{-}} f(x)$$ or $$\lim_{x \to z^{+}} f(x)$$, when side = ‘left’ or side = ‘right’ respectively. See A note on interval endpoints for an explanation.

Parameters
collectionarray-like, dictionary or pandas.Series

The Stairs instances at which to evaluate

xscalar or vector data

The points at which to sample the Stairs instances. Must belong to the step function domain.

side{‘left’, ‘right’}, default ‘right’

if points where step changes occur do not coincide with x then this parameter has no effect. Where a step changes occurs at a point given by x, this parameter determines if the step function is evaluated at the interval to the left, or the right.

Returns
pandas.DataFrame

A dataframe, where rows correspond to the Stairs instances in collection. and columns correspond to the points in x. If collection is a dictionary then the resulting dataframe will be indexed by the dictionary keys. If collection is a pandas.Series then the dataframe will have the same index as the series.

Examples

>>> import staircase as sc
>>> stairs = [s2, s3]
>>> [s2.closed, s3.closed]
["left", "left]

>>> sc.limit(stairs, [2,3,4], side="left"))
2    3    4
0  0.5  0.0 -1.0
1  1.0  NaN  1.0

>>> sc.limit(stairs, [2,3,4], side="right"))
2    3    4
0  0.0 -1.0 -1.0
1  0.0  NaN -1.0

>>> stairs = {"s2":s2, "s3":s3}
>>> sc.limit(stairs, [2,3,4], side="left"))
2    3    4
s1  0.5  0.0 -1.0
s2  1.0  NaN  1.0

>>> index=pd.MultiIndex.from_tuples([("a", "s2"), ("b", "s3")])
>>> stairs = pd.Series([s2,s3], index=index)
>>> sc.limit(stairs, [2,3,4], side="left"))
2    3    4
a s1  0.5  0.0 -1.0
b s2  1.0  NaN  1.0