# A Curve fitting data

Tags:
1. Nov 22, 2016

### bobred

Hi
I have some data from a gamma spectroscopy lab and using a series of known radioactive sources I obtain a calibration curve. The equipment is a scintillation crystal coupled to a photo-multiplier tube connected to a multi-channel analyser to obtain an energy spectrum. Using Excel I add a linear trend line of the form y=mx+c, adding a polynomial of increasing order the equation gives the energy more precisely. Is using a polynomial trend line appropriate or should I be using a linear trend line?

2. Nov 22, 2016

### Staff: Mentor

Sure it is appropriate. However, adding more terms to a model will almost always improve a fit. So the mere fact that a fit is improved is not by itself a good criteria.

The first thing to do is figure if there is a sound theoretical reason to expect a curve of a certain form. You can always do a Taylor series expansion to get a linear term and some correction terms, but having a theory to support your statistical model is always best.

The second thing to do is to look at a plot of your residuals for the linear plot. If the residuals show a quadratic trend then that is a good indication that the extra term is warranted.

Most statistics packages will also let you calculate the AIC or the BIC. Those criteria penalize a model for having too many terms.

3. Nov 22, 2016

### gleem

To clarify you want to produce a calibration curve by fitting a curve to your calibration peak channel no vs their specified energy. You should expect it to be linear for good equipment. How many calibration energies do you have?

4. Nov 22, 2016

### Cutter Ketch

The best answer is if you have a theoretical expectation of the functional form the relation should take.

Ok, you don't have that. The next question is what is the curve for? If it is just going to be used as a calibration curve for that instrument the only rule is you have to avoid lying to yourself.

There are all kinds of good reasons such a calibration curve will be some unknown and not nice shape. This usually happens because there are several different factors contributing all with different functional forms.

It is therefore perfectly valid to try various functional forms trying to find one that reproduces the data within the apparent error bars.

However the trick is to NOT wind up with functional behaviors that aren't really in the data. You want to avoid making functions that have almost as many free parameters as you have data. You can always put a parabola through three points ... or a third order polynomial ... or any higher polynomial. The difference in all those possible shapes gives you an idea of how the fit can lie to you. The way to feel confident is to have a lot of data points and many fewer free parameters in the fit function.

If you do have a lot of data, and you arent really trying to find or understand the functional form of the curve, it is also perfectly valid to average or smooth or do a piece wise fit like a cubic spline. You'll get just as good or better calibration.

5. Nov 22, 2016

### Cutter Ketch

PS: when you are faking it like this beware of extrapolation. A functional form that fits the data you have shouldn't be trusted to say anything beyond the edges of the region the data samples.

6. Nov 22, 2016

### bobred

Thanks for the replies. I have 5 Isotopes but two have multiple peaks, I shall include them and see if this improves things and revert back to a linear fit.

7. Nov 22, 2016

### Khashishi

I suggest using something more powerful than Excel, like R for example. Excel can do unweighted linear fits fine, but requires all sorts of hacks to get weighted fits or nonlinear fits, that you lose the only advantage of excel in simplicity.

8. Nov 22, 2016

### pixel

Can you show us a plot of the data?