linear, moving average curve fits

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Matt

linear, moving average curve fits

Post by Matt » Thu Nov 02, 2000 8:29 pm

Hi everyone,

I've had a conversation about this with David already, but he suggested posting to the group to see if anyone had done some work on this or had any ideas. What I need to do is come up with a way to supply a moving average or a linear fit to a data series. The way I am doing it now is a bit cumbersome. I take the dataset from our database and calculate a linear plot first before creating the DataSource, add the linear plot as a new data series, then return a new Object[][][] with the linear series in it and use this to make my DefaultXYDataSource.

David's suggestion was to create a wrapper class that would take an XYDataSource in its constructor, then overlay the functions on top of it. I think this could work, but one question is how to return the results? It could be as a new DefaultXYDataSource with the linear series added, or it could be just the data series as an ArrayList() or similar. You might call a function with the data series index you want the curve fit to, and it calculates it and returns it as data. The problem is how do we add this new data to the original data source? Maybe XYDataSource needs a new function, like

addDataSeries(Object[][] data),

that will append the new data series to the rest of the Series data.

One other issue is how new functions would be added. Maybe using another class that actually does the calculations and that can be stored in the curve fitting class. As new ones are written, they can just be referenced by the curve fitting class. Or maybe extend an abstract curve fitting class for each type of curve fit. The less flexible way would be to write a new method for each curve fit.

If anyone has any ideas, suggestions, or a need for this type of curve fitting, please post a reply.

Matt

Fabien D.

RE: linear, moving average curve fits

Post by Fabien D. » Fri Dec 01, 2000 8:03 pm

Hi,
I suggest creating :
- an interface XYDataCollection, with add/remove methods.
- AbstractXYDataCollection implementing XYDataCollection and only the listeners methods of XYDataSource with a fireDataSourceChanged() method to send events to listeners when adding/removing series.

Locked