-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Curve Fitting #28
Comments
There are several freely available fitters and spline interpolators in the commons-math project (http://commons.apache.org/proper/commons-math/), e.g. in package fitter and package analysis.interpolation. Disclaimer: I am a developer for commons-math and was looking for a free library to do create some examples for our user-guide. |
Awesome! I'd hate to reinvent the wheel again, so that looks great. Around ten years ago a wrote my own n-degree polynomial curve fitting algorithm in MATLAB using the Newton method. I've recently used the commons-math3 LUDecomposition for matrix math. Are you involved in that? |
BTW, I just released V2.2.0: http://xeiam.com/xchart_changelog.jsp If you want to use XChart for your user guide, it currently has 3 themes you can apply to the Charts: XChart, GGPlot2, and MATLAB. You can always make your own theme as well. I also just added the capability in the release to export charts in high-res, for cases where charts need to end up in printed material. The export method lets you specify the DPI. |
Ok cool. I did write some code in the linear package, but not the LUDecomposition, in case you have any questions or problem just post on the commons-user mailinglist, either me or someone else will quickly response usually. |
@netomi I'm curious if you ever used XChart to publish your user guide? If so, could you post the link here? Cheers! |
@netomi I'm also interested in integrating curve-fitting directly into XChart. Do you have any code to contribute to jump start the effort? |
It is not yet published, some screenshots are committed to the source tree. I will keep you updated on this issue. @curve-fitting: you can take a look at some of the unit-tests at https://svn.apache.org/repos/asf/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/ it is quite straight-forward to use, but I can try to make a contribution if you can give me a bit of a sketch of the API that you would like to see. |
@netomi I took a look at some of the unit tests and gave this some thoughts. Imagine a chart app as shown here. It would probably be better to make the scatter more linear and perhaps create a new ScatterChart05.java class for this first example. The idea would be to be able to very simply create a second Series to add to a chart based on another original series. So in the above example, we have
The best thing would be to extend this as follows:
Behind the scenes, XChart would use The fit series could also be internally styled so that the Markers are turned off by default. Linear, exponential, and n-degree polynomial fits would be the first targets. Histograms with Gaussian fits is also on our wish list, but that would come later... What do you think? |
@netomi Also, I'm curious, what's the difference between the fitting and interpolation packages? |
@fitting vs interpolation: I think a good explanation can be found here: http://siber.cankaya.edu.tr/NumericalComputations/ceng375/node71.html I will take a look the coming days and provide you with some prototype. |
@netomi OK, that's pretty clear. Fitting is what we want (not interpolation), right? Do all the Looking forward to a prototype impl! |
sorry for the delay, but I was quite busy. You can see a demo in my forked branch. Examples are LineChart07 or AreaChart01. The idea is to support an interpolation type for each Series. The default would be linear, but a user can select also Spline. There are a few things missing:
I wanted to get feedback from you and then I can clean up my contribution. |
I'll take a look at this ASAP. I'm really busy at the moment. |
On 08/30/2013 11:10 AM, Tim Molter wrote:
ok
ok
I was unsure if you wanted to have a dependency to another lib, The import is an artifact as I had commons-math first as a dependency,
ok.
Well, it was just a quick and dirty proof of concept. There are several One thing I was wondering about: is there a specific reason why you do Thomas |
Damn, that's a large dependency. Let's just keep it how you have it then for now. We can always change it later.
Good question. I think I was looking for an Object to encapsulate both floating point numbers and integers. When representing Integers with a Double, precision or exactness gets lost of course. Also, for Dates, representing the epoch time which is a long as a double seems strange. But you could totally be right. What would you suggest? ~Tim |
On 08/31/2013 09:05 PM, Tim Molter wrote:
There is nothing wrong to represent an integer value with a double (as For the y Axis, converting the data to a BigDecimal is a complete waste, For the x Axis, where the data could be Dates represented as long, it As long as you do not do process money values or do scientific computing In my fork, I did the necessary changes in the PlotContentLineChart Thomas |
@netomi I will get rig of the BigDecimals like you suggest. Thanks for spotting that! I don't see any recent changes in your fork. Perhaps you forgot to push. For moving forward it would be great if you could submit a pull request against the develop branch for what you've done so far plus the minor clean up things we've talked about. I'd be happy with giving to direct write access to the project if you'd like as well. |
On 09/03/2013 12:03 PM, Tim Molter wrote:
Sorry for my late reply, I currently have some visitors at home and can I did not push yet as I was not really happy with my changes wrt min/max Thomas |
@netomi Take your time. No rush. :) |
@netomi I got rid of all |
Great! btw. xchart is now officially part of the commons-math userguide projects, see here https://svn.apache.org/repos/asf/commons/proper/math/trunk/src/userguide/. Results can be seen in the userguide section on the homepage: http://commons.apache.org/proper/commons-math/userguide/distribution.html But there are more to come, just in case you are interested to hear about it. |
Yes, I'm definitely interested, so thanks for sharing! I'm very pleased to see XChart being used. Let me know when there is more to see. I must say, the charts look really great on the userguide. FYI, I recently released version 2.3.0, which includes the BigDecimal --> double refactor, as well as real-time charts. As far as integrating curve-fitting into XChart, I think it would be nice to add I was also wondering if |
Adding commons-math as an optional dependency should work, and you may benefit from other tools there as well. I got a bit distracted with the curve fitting contribution but I am still willing to help with that. Regarding the histogram, there is a nice example on this stackoverflow page (the answer with the EmpiricalDistribution): |
@netomi After some thinking, I cannot decide if it is wise to include curve fitting into XChart, but rather keep XChart strictly for plotting data provided from the outside. In this case, people can just create their own series with the fitting capabilities of FYI, check out the Did you ever consider refactoring |
Ok thanks, I will soon update the dependency and check the new styles. @math: it is quite unlikely that math will become a multi-module project, but if you have a good argument for this you can really bring this up on the mailinglist. |
Decided to leave this out of XChart. People can generate their own fit data. Maybe I'll make some examples using |
Polynomial, exponential, Gaussian, others...
The text was updated successfully, but these errors were encountered: