Take the 2-minute tour ×

I'd like to fit a function to the Sun's electrons flux data (blue dots), please note that x,y axis are in the log scale. The green dots are the "best" fit from the gnuplot program. I have taken the a/x as a test function, but in the log scale that is a linear function. Could anyone give me advice which test function should I take? Great thanks for any advice:)

x - electrons energy [MeV], y - flux

share|improve this question
BTW---$ax^b$ is a line when plotted log--log and collectively these are called "power laws". –  dmckee Jul 20 '12 at 15:13

3 Answers 3

up vote 1 down vote accepted

It would be helpful to include what the x/y axes represent -- the physics of the problem may suggest an answer.

For a generic approach you could just (explicitly) construct $y'=\ln y$, $x'=\ln x$ and then do polynomial fits to this data $x',y'$.

A functional form that might be worth considering is $y = c x^{a +b x}$ which could give you the curvature you're seeing in the log-log plot, but I'd only go there if there was some physical motivation for the $x^{bx}$ behaviour.

share|improve this answer
the x axis is an energy [MeV] of electrons; y axis is a flux e- cm^-2 s^-1. –  nykon Jul 20 '12 at 14:38

In general you don't want to be thinking "How do I fit to this data set?", but rather "What physics do I suspect here and how should I parameterize it?" so that your fit is physically meaningful.

share|improve this answer

You probably have too few points to get a physically significant fit. To get the curvature on the log scale you might try $$\ln(y)=a\left(\ln(x)\right)^2+b\ln(x)+c,$$ i.e. fitting a parabola to those points, but it's unclear that that will give you anything of value (it gives the model $y=Cx^{b+a\ln(x)}$ which is pretty ugly).

I would say you're doing this the wrong way round: start with physical considerations to derive some kind of model and then do a fit to see if it works. The problem is that there is probably a large number of different curves that will fit those points well enough, and more so if you allow more than three or four parameters. The only way out (and even then I'd say it's a feeble one) is to get a large amount of data with large precision. Then, if a model with only a few parameters fits all your points within their uncertainty, you're on to something that theory has to account for.

It also depends on what you want your fit to do. Do you expect some kind of theoretical insight? then look to theory. Do you want to interpolate your data? then there are ready-made interpolation algorithms (some, but not all, of which include a polynomial fit to the data, though they are not usually least-squares fits to all the data but rather exact fits to part of the data). Do you want some kind of derivative or integral from that curve? then evaluate it numerically. And so on.

share|improve this answer
Thank You for a good advices. The best scenario is to get the function describing the data. But I think I have to take polynomials into consideration. –  nykon Jul 20 '12 at 15:58
This it the way to approach the problem as pure mathematics, but fitting without a physics motivation is very rarely a good idea. –  dmckee Jul 20 '12 at 16:51
+1 to dmckee. You won't get a physically meaningful "function describing the data" without some physical insight about what your data is describing. –  Emilio Pisanty Jul 22 '12 at 12:58

Your Answer


