I'm trying to get a better handle on fitting (using NonlinearModelFit and Fit), and I can't understand why my test problem doesn't work. I'm generating a set of points on a half circle, with some added noise:
randomNums = Table[{x, Sqrt[5^2 - x^2] + Random[]}, {x, -5, 5, 0.5}]
Next I'm simply trying to fit a nlm to this set of data:
nlm = NonlinearModelFit[ randomNums, a Sqrt[b r^2 - c x^2] + d, {a, b, c, d, r}, x ]
However, this just throws back an error that I don't understand:
NonlinearModelFit::nrlnum: The function value {0.653833 +4.89898 I,-2.09763+4.38748 I,-2.43186+3.87298 I,-2.89856+3.3541 I,-3.65104+2.82843 I,-3.59796+2.29129 I,-3.77146+1.73205 I,-4.11906+1.11803 I,-4.72929+0. I,-3.72242+0. I,-3.8093+0. I,-4.07116+0. I,-4.22766+0. I,-4.74941+1.11803 I,-3.93771+1.73205 I,-4.14349+2.29129 I,-3.93865+2.82843 I,-3.55063+3.3541 I,-2.80604+3.87298 I,-1.3348+4.38748 I,0.0544825 +4.89898 I} is not a list of real numbers with dimensions {21} at {a,b,c,d,r} = {1.,1.,1.,1.,1.}.