ace.smoother module
Scatterplot smoother with a fixed span.
Takes x,y scattered data and returns a set of (x,s) points that form a smoother curve fitting the data with moving least squares estimates. Similar to a moving average, but with better characteristics. The fundamental issue with this smoother is that the choice of span (window size) is not known in advance. The SuperSmoother uses these smoothers to figure out which span is optimal.
This is a Python port of J. Friedman’s 1982 fixed-span Smoother [Friedman82]
Example:
s = Smoother()
s.specify_data_set(x, y, sort_data = True)
s.set_span(0.05)
s.compute()
smoothed_y = s.smooth_result
- class ace.smoother.Smoother[source]
Bases:
objectSmoother that accepts data and produces smoother curves that fit the data.
- specify_data_set(x_input, y_input, sort_data=False)[source]
Fully define data by lists of x values and y values.
This will sort them by increasing x but remember how to unsort them for providing results.
- Parameters:
- x_inputiterable
list of floats that represent x
- y_inputiterable
list of floats that represent y(x) for each x
- sort_databool, optional
If true, the data will be sorted by increasing x values.
- class ace.smoother.BasicFixedSpanSmoother[source]
Bases:
SmootherA basic fixed-span smoother.
Simple least-squares linear local smoother.
Uses fast updates of means, variances.
- class ace.smoother.BasicFixedSpanSmootherSlowUpdate[source]
Bases:
BasicFixedSpanSmootherUse slow means and variances at each step. Used to validate fast updates.
- ace.smoother.DEFAULT_BASIC_SMOOTHER
alias of
BasicFixedSpanSmoother
- ace.smoother.perform_smooth(x_values, y_values, span=None, smoother_cls=None)[source]
Run the basic smoother (convenience function).
- Parameters:
- x_valuesiterable
List of x value observations
- y_ valuesiterable
list of y value observations
- spanfloat, optional
Fraction of data to use as the window
- smoother_clsClass
The class of smoother to use to smooth the data
- Returns:
- smootherobject
The smoother object with results stored on it.