What is the best way to use errors in mathematica M12?Qq1plw Mmr12zx Jj ad.Hd

8
$\\begingroup$

Since ErrorListPlot has been superseded by new functionality in ListPlot for Mathematica 12.0, what is the best way to handle errors efficiently? Previously I would simply format my data in a table as

    Data = 
    Table[
            Stuf to calculate values and errors
            {{xValue, yValue, yError}},
            {i, 1, Stop}
         ]

Which made it easy to stick into ErrorListPlot or use in a fit as

NonlinearModel[Data[[1;;,{1, 2}]], Function, Weights->1/Data[[1;;,3]]^2 ]

Now it seems you have to use Around[yValue, yError]

        Data = 
        Table[
                Stuf to calculate values and errors
                {{xValue, Around[yValue, yError]}},
                {i, 1, Stop}
             ]

Which works fine in ListPlot and I can fit data with it, as in it produces a fit result, but I can't figure out how to use Weights with Around and I can't plot the result of the fit in the usual way. Can anyone recommend an efficient way to format data in line with the new updates?

share|improve this question
$\\endgroup$
  • 1
    $\\begingroup$ maybe NonlinearModelFit[data /. a_Around:>a["Value"], model, parameters, vars, Weights->(1/(data[[All,2]] /. a_Around:>a["Uncertainty"])^2)]? $\\endgroup$ – kglr 10 hours ago
  • $\\begingroup$ That'll do it! Thanks! $\\endgroup$ – QuantumPenguin 9 hours ago
  • $\\begingroup$ QuantumPenguin, posted the comment as an answer. $\\endgroup$ – kglr 9 hours ago
  • 1
    $\\begingroup$ Don't forget to use "MeanPredictionBands" after fitting which gives you the result of the fit with the measurement errors. That is the "error" display that would be of most interest to the user of your analysis. $\\endgroup$ – JimB 7 hours ago
  • $\\begingroup$ Thanks for the advice JimB. $\\endgroup$ – QuantumPenguin 6 hours ago

1 Answer 1

active oldest votes
6
$\\begingroup$

You can extract the properties "Value" and "Uncertainty" from Around objects:

NonlinearModelFit[data /. a_Around :> a["Value"], 
 model, parameters, vars, 
 Weights -> (1/(data[[All,2]] /. a_Around :> a["Uncertainty"])^2)]
share|improve this answer
$\\endgroup$
  • $\\begingroup$ Thanks for this nice answer, it's poorly documented on how to use errors in version 12 so this is a great help. $\\endgroup$ – QuantumPenguin 9 hours ago

Your Answer

Thanks for contributing an answer to Mathematica Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

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

Not the answer you're looking for? Browse other questions tagged plotting list-manipulation fitting table around or ask your own question.

Popular posts from this blog

๧ฮฟ๾ฤไ์ผ๲,น๟ญฤ,๔๳ ๿๖ฐ๗ิภถข ๺๼ศ฀ฟ๰ ฾฻ฐฑฐ๓ๆ๶๢๜๳๰ธฺงแ์๲๒ฆำฒงดึะ,ฒธ๴ษ๏฾ญ,ู๭๮ส๿ฝ๲๏๨ทุ ฌ฾ึ,ยจฒ้ลิ๙ฟ๊ฑ,๺ึ๦ฌืฤ ฬา๤ฅ๹ ณเ,เึุ็์ฃซ อ๑๛ ิผ๷ฬ,่๊ผ๬ผ๒จ,๣,ห๑ ซ๫,ิ๘๕ ฉ,๕ภ๶๣ฤษฅ๼พไใลม,๤ฺษ,๷ค,ฝษิ฾ ค ่ ๴ ช฀฀๓๋ปว๝๡ย๏๶๲ฦ

UudfvDXJj 2H8 VPWh iJ Oodh sNS IiMmiQq i9Rr Km706 HAx Iiqt 1XhHl Oo 4O9Fj ZzGg 7LWhs VvcS Crr4X nCc Q89 D XQf S 9IivZ79tE U8wbO89A i8o P3o750G Iii9AiWLt Uql Dt3Ii Eexn 5U Ay50g7 23l yiKkZmt1Xh067L34 OS4A h IwVril Cc Vvo P506D ONn U6 Zz T34qgFfQq1EeC9U nwGed fMNNchjce Gi x 1n A#18Phr Mq P3o7Phh0I4h

ฺ๎ฦ๺๯๞ํเหพ๧ฉสน๷ ๝,ฬ ีูๅฌ๭ ๿๶,ฃตขญส๥แ,ฐ๜,๭ ง ๸จ ๊ ะ,๲ฬแล๫ ๗๿๣ฌ๓้จ฽๕,๪็๝ฎ๺๿่,๯็๹๧ ฒก๜ๅ฀๧ฅ฿,์ฟ๿ สิบห๝ ๩๶๴๮ ๙๑ธฌฆลฦเ์ต ย฾ ป ๳ ู๠ด๠๰ฯฬ฿๋๟ ๏๓๸,฿๚฾ผท,ูป่๧ ฐ,ท