ChartDirector 7.1 (C++ Edition)

ArrayMath.lowess


Usage

ArrayMath& lowess(double smoothness = 0.25, int iteration = 0);

Description

Fits a curve through the data points in the ArrayMath object using the LOWESS algorithm.

The full name of LOWESS is "Robust locally weighted regression and smoothing scatterplots". It is a commonly used algorithm for drawing a smooth curve through a number of points.

LOWESS works by assuming a small segment of any curve can be approximated by a straight line. For each data point, LOWESS finds the n nearest points to that data point (n is configurable), and performs weighted linear regression using a tricube weighting function. It then adjust the coordinates of the data point based on the result of the weighted linear regression.

LOWESS can run in multiple iterations, in which case it should converge to a stable curve - thus it is called "robust".

In most cases, LOWESS behaves better than many other smoothing algorithms, such as moving average, moving median, exponential average. Curves draw using LOWESS look smoother, yet they track the data points better. Also, LOWESS behaves well at the end points. On the other hand, methods based on moving windows (e.g. moving averages) do not work on the first few data points, because they need sufficient data points to fill the moving window first.

In this method, each element of the ArrayMath object will be replaced by the corresponding value computed using the LOWESS algorithm.

Arguments

ArgumentDefaultDescription
smoothness0.25The smoothness factor. It must be between 0 - 1. It is the portion of points used in finding the n nearest points. In other words, n = smoothness * no_of_points. A larger value will result in a smoother the curve. A smaller value will result in the curve tracking the data points better.

For LOWESS to have any smoothing effect at all, n must be at least 3. You may need to use a large smoothness factor if you only have a few data points.
iteration0The number of additional iteration used in the LOWESS algorithm. Unless your data is extremely noisy, in most case no additional iteration is necessary.

Return Value

The current ArrayMath object.