Ask Your Question
0

weird behaviour of find_fit

asked 2012-07-04 08:21:54 +0100

god.one gravatar image

updated 2012-07-04 08:38:45 +0100

Hi and sorry for the strange headline, my problem is this:

data=[[0.78344E-02,0.15668E-01],[0.23501E-01,0.15664E-01],[0.39162E-01,0.15657E-01],[0.54813E-01,0.15645E-01],[0.70451E-01,0.15630E-01],[0.86071E-01,0.15611E-01],[0.10167E+00,0.15588E-01],[0.11725E+00,0.15561E-01],[0.13279E+00,0.15530E-01],[0.14830E+00,0.15496E-01],[0.16378E+00,0.15457E-01],[0.17922E+00,0.15415E-01],[0.19461E+00,0.15369E-01],[0.20995E+00,0.15320E-01],[0.22525E+00,0.15266E-01],[0.24049E+00,0.15209E-01],[0.25566E+00,0.15148E-01],[0.27078E+00,0.15083E-01],[0.28583E+00,0.15015E-01],[0.30081E+00,0.14943E-01],[0.31571E+00,0.14867E-01],[0.33054E+00,0.14788E-01],[0.34529E+00,0.14705E-01],[0.35995E+00,0.14618E-01],[0.37452E+00,0.14528E-01],[0.38901E+00,0.14434E-01],[0.40339E+00,0.14337E-01],[0.41768E+00,0.14236E-01],[0.43186E+00,0.14132E-01],[0.44594E+00,0.14024E-01],[0.45991E+00,0.13913E-01],[0.47377E+00,0.13799E-01],[0.48751E+00,0.13681E-01],[0.50113E+00,0.13559E-01],[0.51463E+00,0.13435E-01],[0.52800E+00,0.13306E-01],[0.54124E+00,0.13175E-01],[0.55435E+00,0.13041E-01],[0.56732E+00,0.12903E-01],[0.58015E+00,0.12762E-01],[0.59284E+00,0.12619E-01],[0.60539E+00,0.12471E-01],[0.61778E+00,0.12321E-01],[0.63003E+00,0.12168E-01],[0.64212E+00,0.12012E-01],[0.65405E+00,0.11852E-01],[0.66582E+00,0.11691E-01],[0.67743E+00,0.11525E-01],[0.68887E+00,0.11358E-01],[0.70015E+00,0.11187E-01],[0.71125E+00,0.11015E-01],[0.72217E+00,0.10838E-01],[0.73292E+00,0.10660E-01],[0.74349E+00,0.10478E-01],[0.75388E+00,0.10295E-01],[0.76408E+00,0.10108E-01],[0.77409E+00,0.99195E-02],[0.78392E+00,0.97277E-02],[0.79355E+00,0.95348E-02],[0.80299E+00,0.93382E-02],[0.81223E+00,0.91405E-02],[0.82127E+00,0.89392E-02],[0.83010E+00,0.87372E-02],[0.83874E+00,0.85317E-02],[0.84717E+00,0.83254E-02],[0.85539E+00,0.81160E-02],[0.86340E+00,0.79048E-02],[0.87120E+00,0.76925E-02],[0.87878E+00,0.74771E-02],[0.88615E+00,0.72611E-02],[0.89330E+00,0.70421E-02],[0.90024E+00,0.68223E-02],[0.90695E+00,0.66003E-02],[0.91344E+00,0.63765E-02],[0.91970E+00,0.61519E-02],[0.92574E+00,0.59252E-02],[0.93155E+00,0.56977E-02],[0.93713E+00,0.54676E-02],[0.94249E+00,0.52370E-02],[0.94761E+00,0.50054E-02],[0.95250E+00,0.47718E-02],[0.95715E+00,0.45371E-02],[0.96157E+00,0.43020E-02],[0.96575E+00,0.40653E-02],[0.96970E+00,0.38276E-02],[0.97341E+00,0.35894E-02],[0.97688E+00,0.33497E-02],[0.98011E+00,0.31091E-02],[0.98310E+00,0.28688E-02],[0.98584E+00,0.26270E-02],[0.98835E+00,0.23846E-02],[0.99061E+00,0.21412E-02],[0.99263E+00,0.18984E-02],[0.99441E+00,0.16541E-02],[0.99594E+00,0.14099E-02],[0.99723E+00,0.11651E-02],[0.99827E+00,0.91946E-03],[0.99907E+00,0.67542E-03],[0.99962E+00,0 ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-07-04 09:25:03 +0100

Volker Braun gravatar image

The data that you have hints at a singularity at x=1 with data points concentrated around there. And the model isn't particularly good. This makes the nonlinear fit numerically very unstable. Compare with this:

sage: data = <same as before>
sage: var('a,b,x')
(a, b, x)
sage: model=a*(1-x)^b
sage: fit = find_fit(data,model,variables=[x],initial_guess=(1,1)); fit
[a == 0.017034240977895455, b == 0.3870748290050979]
sage: point2d(data) + plot(model.subs(a=fit[0].rhs(), b=fit[1].rhs()), 0, 1)

image description

edit flag offensive delete link more
1

answered 2012-07-04 09:49:01 +0100

god.one gravatar image

Hi Volker,

if you take the model

model=a*sqrt(1-b*x^2)

and as an initial guess (1,0.00025) (a good guess made by interact) I get

[a == 1.0000027991978133, b == 0.00024550730310659858]

and if you compare this function with the data provided it looks very good (since I do not know how to post pictures I cannot show you my plot).

Concerning the points around x=1: I have deleted some points from the list near the end and the problem vanishes (I can switch a and b or make some other guesses and the above mentioned solution will be calculated).

But thank you for your fast answer.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-07-04 08:21:54 +0100

Seen: 462 times

Last updated: Jul 04 '12