Logo

statsmodels.distributions.empirical_distribution.StepFunction

class statsmodels.distributions.empirical_distribution.StepFunction(x, y, ival=0.0, sorted=False, side='left')[source]

A basic step function.

Values at the ends are handled in the simplest way possible: everything to the left of x[0] is set to ival; everything to the right of x[-1] is set to y[-1].

Parameters:

x : array-like

y : array-like

ival : float

ival is the value given to the values to the left of x[0]. Default is 0.

sorted : bool

Default is False.

side : {‘left’, ‘right’}, optional

Default is ‘left’. Defines the shape of the intervals constituting the steps. ‘right’ correspond to [a, b) intervals and ‘left’ to (a, b].

Examples

>>> import numpy as np
>>> from statsmodels.distributions.empirical_distribution import StepFunction
>>>
>>> x = np.arange(20)
>>> y = np.arange(20)
>>> f = StepFunction(x, y)
>>>
>>> print(f(3.2))
3.0
>>> print(f([[3.2,4.5],[24,-3.1]]))
[[  3.   4.]
 [ 19.   0.]]
>>> f2 = StepFunction(x, y, side='right')
>>>
>>> print(f(3.0))
2.0
>>> print(f2(3.0))
3.0

Methods

Previous topic

statsmodels.distributions.empirical_distribution.ECDF

Next topic

statsmodels.sandbox.distributions.extras.SkewNorm_gen

This Page