How to fit the data?












1












$begingroup$


Here is my attempt.



data = {{0., 2.61}, {0.1, 2.62}, {0.2, 2.62}, {0.3, 2.62}, {0.4, 
2.63}, {0.5, 2.63}, {0.6, 2.74}, {0.7, 2.98}, {0.8, 3.66}, {0.9,
5.04}, {1., 7.52}, {1.1, 10.74}, {1.2, 12.62}, {1.3, 10.17}, {1.4,
5}, {1.5, 2.64}, {1.6, 11.5}, {1.65, 35.4}};
NonlinearModelFit[data,a*Cosh[b*x^c*Sin[d*x^e]], {{a, 3}, {b, 0.2}, {c, 1}, {d, 1},
{e, 3}}, x, Method -> "LevenbergMarquardt"]



NonlinearModelFit::nrjnum: The Jacobian is not a matrix of real numbers at {a,b,c,d,e} = {3.,0.2,1.,1.,3.}.




The same issues appear with other initial points. As far as I know it, a good fit with the residuals of quantity $0.01$ exists and can be found with Mathcad (not MATLAB).










share|improve this question









$endgroup$








  • 2




    $begingroup$
    The Jacobian contains Log[x] and your data contains x == 0
    $endgroup$
    – Coolwater
    1 hour ago












  • $begingroup$
    @Coolwater: There are other methods of fitting.
    $endgroup$
    – user64494
    33 mins ago
















1












$begingroup$


Here is my attempt.



data = {{0., 2.61}, {0.1, 2.62}, {0.2, 2.62}, {0.3, 2.62}, {0.4, 
2.63}, {0.5, 2.63}, {0.6, 2.74}, {0.7, 2.98}, {0.8, 3.66}, {0.9,
5.04}, {1., 7.52}, {1.1, 10.74}, {1.2, 12.62}, {1.3, 10.17}, {1.4,
5}, {1.5, 2.64}, {1.6, 11.5}, {1.65, 35.4}};
NonlinearModelFit[data,a*Cosh[b*x^c*Sin[d*x^e]], {{a, 3}, {b, 0.2}, {c, 1}, {d, 1},
{e, 3}}, x, Method -> "LevenbergMarquardt"]



NonlinearModelFit::nrjnum: The Jacobian is not a matrix of real numbers at {a,b,c,d,e} = {3.,0.2,1.,1.,3.}.




The same issues appear with other initial points. As far as I know it, a good fit with the residuals of quantity $0.01$ exists and can be found with Mathcad (not MATLAB).










share|improve this question









$endgroup$








  • 2




    $begingroup$
    The Jacobian contains Log[x] and your data contains x == 0
    $endgroup$
    – Coolwater
    1 hour ago












  • $begingroup$
    @Coolwater: There are other methods of fitting.
    $endgroup$
    – user64494
    33 mins ago














1












1








1





$begingroup$


Here is my attempt.



data = {{0., 2.61}, {0.1, 2.62}, {0.2, 2.62}, {0.3, 2.62}, {0.4, 
2.63}, {0.5, 2.63}, {0.6, 2.74}, {0.7, 2.98}, {0.8, 3.66}, {0.9,
5.04}, {1., 7.52}, {1.1, 10.74}, {1.2, 12.62}, {1.3, 10.17}, {1.4,
5}, {1.5, 2.64}, {1.6, 11.5}, {1.65, 35.4}};
NonlinearModelFit[data,a*Cosh[b*x^c*Sin[d*x^e]], {{a, 3}, {b, 0.2}, {c, 1}, {d, 1},
{e, 3}}, x, Method -> "LevenbergMarquardt"]



NonlinearModelFit::nrjnum: The Jacobian is not a matrix of real numbers at {a,b,c,d,e} = {3.,0.2,1.,1.,3.}.




The same issues appear with other initial points. As far as I know it, a good fit with the residuals of quantity $0.01$ exists and can be found with Mathcad (not MATLAB).










share|improve this question









$endgroup$




Here is my attempt.



data = {{0., 2.61}, {0.1, 2.62}, {0.2, 2.62}, {0.3, 2.62}, {0.4, 
2.63}, {0.5, 2.63}, {0.6, 2.74}, {0.7, 2.98}, {0.8, 3.66}, {0.9,
5.04}, {1., 7.52}, {1.1, 10.74}, {1.2, 12.62}, {1.3, 10.17}, {1.4,
5}, {1.5, 2.64}, {1.6, 11.5}, {1.65, 35.4}};
NonlinearModelFit[data,a*Cosh[b*x^c*Sin[d*x^e]], {{a, 3}, {b, 0.2}, {c, 1}, {d, 1},
{e, 3}}, x, Method -> "LevenbergMarquardt"]



NonlinearModelFit::nrjnum: The Jacobian is not a matrix of real numbers at {a,b,c,d,e} = {3.,0.2,1.,1.,3.}.




The same issues appear with other initial points. As far as I know it, a good fit with the residuals of quantity $0.01$ exists and can be found with Mathcad (not MATLAB).







fitting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









user64494user64494

3,28111021




3,28111021








  • 2




    $begingroup$
    The Jacobian contains Log[x] and your data contains x == 0
    $endgroup$
    – Coolwater
    1 hour ago












  • $begingroup$
    @Coolwater: There are other methods of fitting.
    $endgroup$
    – user64494
    33 mins ago














  • 2




    $begingroup$
    The Jacobian contains Log[x] and your data contains x == 0
    $endgroup$
    – Coolwater
    1 hour ago












  • $begingroup$
    @Coolwater: There are other methods of fitting.
    $endgroup$
    – user64494
    33 mins ago








2




2




$begingroup$
The Jacobian contains Log[x] and your data contains x == 0
$endgroup$
– Coolwater
1 hour ago






$begingroup$
The Jacobian contains Log[x] and your data contains x == 0
$endgroup$
– Coolwater
1 hour ago














$begingroup$
@Coolwater: There are other methods of fitting.
$endgroup$
– user64494
33 mins ago




$begingroup$
@Coolwater: There are other methods of fitting.
$endgroup$
– user64494
33 mins ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

Below err is defined as the residual sum of squares. Using ?NumericQ on one of the arguments prevents FindMinimum from exact differentiation. In that way no problem arises even though the point with x == 0 is included.



err[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ data];

res[x_] = a*Cosh[b*x^c*Sin[d*x^e]] /. Last[FindMinimum[err[a, b, c, d, e], {
{a, 3, 1/100, 25}, {b, 2, 1/100, 25}, {c, 1, 1/100, 25},
{d, 23/10, 1/100, 25}, {e, 2, 1/100, 25}}, Method -> "InteriorPoint"]]

Show[Plot[res[x], {x, 0, 1.65}, PlotRange -> All], ListPlot[data]]







share|improve this answer









$endgroup$













  • $begingroup$
    Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
    $endgroup$
    – user64494
    35 mins ago













Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190407%2fhow-to-fit-the-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3












$begingroup$

Below err is defined as the residual sum of squares. Using ?NumericQ on one of the arguments prevents FindMinimum from exact differentiation. In that way no problem arises even though the point with x == 0 is included.



err[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ data];

res[x_] = a*Cosh[b*x^c*Sin[d*x^e]] /. Last[FindMinimum[err[a, b, c, d, e], {
{a, 3, 1/100, 25}, {b, 2, 1/100, 25}, {c, 1, 1/100, 25},
{d, 23/10, 1/100, 25}, {e, 2, 1/100, 25}}, Method -> "InteriorPoint"]]

Show[Plot[res[x], {x, 0, 1.65}, PlotRange -> All], ListPlot[data]]







share|improve this answer









$endgroup$













  • $begingroup$
    Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
    $endgroup$
    – user64494
    35 mins ago


















3












$begingroup$

Below err is defined as the residual sum of squares. Using ?NumericQ on one of the arguments prevents FindMinimum from exact differentiation. In that way no problem arises even though the point with x == 0 is included.



err[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ data];

res[x_] = a*Cosh[b*x^c*Sin[d*x^e]] /. Last[FindMinimum[err[a, b, c, d, e], {
{a, 3, 1/100, 25}, {b, 2, 1/100, 25}, {c, 1, 1/100, 25},
{d, 23/10, 1/100, 25}, {e, 2, 1/100, 25}}, Method -> "InteriorPoint"]]

Show[Plot[res[x], {x, 0, 1.65}, PlotRange -> All], ListPlot[data]]







share|improve this answer









$endgroup$













  • $begingroup$
    Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
    $endgroup$
    – user64494
    35 mins ago
















3












3








3





$begingroup$

Below err is defined as the residual sum of squares. Using ?NumericQ on one of the arguments prevents FindMinimum from exact differentiation. In that way no problem arises even though the point with x == 0 is included.



err[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ data];

res[x_] = a*Cosh[b*x^c*Sin[d*x^e]] /. Last[FindMinimum[err[a, b, c, d, e], {
{a, 3, 1/100, 25}, {b, 2, 1/100, 25}, {c, 1, 1/100, 25},
{d, 23/10, 1/100, 25}, {e, 2, 1/100, 25}}, Method -> "InteriorPoint"]]

Show[Plot[res[x], {x, 0, 1.65}, PlotRange -> All], ListPlot[data]]







share|improve this answer









$endgroup$



Below err is defined as the residual sum of squares. Using ?NumericQ on one of the arguments prevents FindMinimum from exact differentiation. In that way no problem arises even though the point with x == 0 is included.



err[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ data];

res[x_] = a*Cosh[b*x^c*Sin[d*x^e]] /. Last[FindMinimum[err[a, b, c, d, e], {
{a, 3, 1/100, 25}, {b, 2, 1/100, 25}, {c, 1, 1/100, 25},
{d, 23/10, 1/100, 25}, {e, 2, 1/100, 25}}, Method -> "InteriorPoint"]]

Show[Plot[res[x], {x, 0, 1.65}, PlotRange -> All], ListPlot[data]]








share|improve this answer












share|improve this answer



share|improve this answer










answered 56 mins ago









CoolwaterCoolwater

14.8k32553




14.8k32553












  • $begingroup$
    Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
    $endgroup$
    – user64494
    35 mins ago




















  • $begingroup$
    Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
    $endgroup$
    – user64494
    35 mins ago


















$begingroup$
Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
$endgroup$
– user64494
35 mins ago






$begingroup$
Thank you. Likely a somewhat better fit than your $2.75699 cosh left(1.66039 x^{2.92883} sin left(4.74005 x^{0.70619}right)right) $ is $[a= 2.61748239217892,b= 1.71949328471199,c= 2.30924398627606,d= 1.50333104215966,e= 1.84597270613482]$. Can you kindly compare the results?
$endgroup$
– user64494
35 mins ago




















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190407%2fhow-to-fit-the-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Why is a white electrical wire connected to 2 black wires?

Waikiki

What are all the squawk codes?