I'm currently trying to fit Planck's law (B[λ, T]) to measurements, thereby determining Planck's constant.

I have a list of triplets containing wavelength, temperature and measured intensity and a list of triplets with their errors, like:

datalist  = {{λ1, T1, B1}, {λ2, T2, B2}, ...}    
errorlist = {{σλ1, σT1, σB1}, {σλ2, σT2, σB2}, ...}

Although NonlinearModelFit can fit functions of the type R2 → R, it seems to only accept a one dimensional list as Weights. This is what I tried:

NonlinearModelFit[datalist, B[λ, T], {{h, hlit}}, {λ,T}, Weights -> (errorlist)^-2]

I could of course propagate the partial uncertainties to create one uncertainty for each triplet, thereby have a one dimensional Weights list instead, but it seems a bit unethic.

Would it be possible to fit Planck's curve to my measurements without having to combine the errors first?

Edit: Here's the exact error message that I get:

NonlinearModelFit::wts: The value of option Weights -> {{100.,100.,2500.},{11.1111,25.,25.},{11.1111,2.77778,11.1111}} should be a list of real numbers or a pure function. >>

(I used this data and function as an example: http://pastebin.com/pqxDfe4u)

  • $\begingroup$ please post a link to your data and error? $\endgroup$ – chris Jun 5 '13 at 20:32
  • $\begingroup$ Hi chris, I've included the error message and some example data in the original post. (I'm actually fitting the ratio of two Planck functions, so included an example function to keep things simple.) $\endgroup$ – Blue Jun 5 '13 at 21:27
  • $\begingroup$ it seems this works: NonlinearModelFit[datalist, F[x, y], {{a, 2}}, {x, y} , Weights -> Last/@(errorlist)] but may be you want errors in x and y as well? $\endgroup$ – chris Jun 5 '13 at 21:30
  • $\begingroup$ Yes, i would like to include all the uncertainties. If plotted, it would look like every data point is surrounded by a cube, instead of a line normal to the λT-plane. $\endgroup$ – Blue Jun 5 '13 at 21:56
  • $\begingroup$ What I have done in the past is simply to multiply the reciprocal variances in the abscissa and the ordinate together and use that as a weight. Of course, that is not strictly correct, but it will be a reasonable approximation if the residuals are small. If you want it done strictly correctly (i.e. through total least squares), NonlinearModelFit can't help you--you'll have to code it yourself. $\endgroup$ – Oleksandr R. Jun 6 '13 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.