
This example demonstrates the LOWESS general purpose curve fitting that is built into ChartDirector.
In linear regression, the relationship among the x and y coordinates are assumed to be linear.
However, in many applications, that relationship cannot be assumed to be linear. It can be polynomial, exponential, logarithmic, gaussian, sinusoidal, etc. In many cases, the relationship is not even known.
To solve this kind of problems, ChartDirector supports a general curve fitting algorithm known as LOWESS using ArrayMath.lowess and ArrayMath.lowess2.
LOWESS works by assuming a small segment of any curve can be approximated by a straight line. For each data point, LOWESS performs a weighted linear regression using nearby points. It then adjusts the data point using the result of the linear regression. The adjusted data points should lie on the smooth curve reflecting the underlying relationship. For further details, please refer to ArrayMath.lowess.
The LOWESS algorithm only adjusts the points to smoothen them. They still need to be joined together. In this example, the adjusted points are joined with a spline layer using XYChart.addSplineLayer.