Re: Circle Fit
- To: mathgroup at smc.vnet.net
- Subject: [mg38566] Re: Circle Fit
- From: Nigel King <king at dircon.co.uk>
- Date: Fri, 27 Dec 2002 02:14:57 -0500 (EST)
- References: <aueij4$522$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In <aueij4$522$1 at smc.vnet.net> Dieter Palme wrote: > Hi experts, > I have a set of points (xi, yi), i>30. I search for a solution to fit > a circle (x-x0)^2 + (y-y0)^2 = r^2 to these points. I need r and sigma_ > r. It could be helpful to get x0,y0 also, but it is not nessecary. I > found a algorythm for another system (LeastSquareFit) but not for > Mathematica 4. Who can help? Thanks in advance Dieter > This is what I might do; Get in the statistics add on In[1]:= Needs["Statistics`NormalDistribution`"] Create some test values of (xi, yi) In[2]:= r = 3.3; x0 = 1.2; y0 = 3.4; sigmar = .3; n = 50; In[3]:= t = Map[{x0 + (r + #[[1]])Sin[#[[2]]], y0 + (r + #[[1]])Cos[#[[2]]]} &, Transpose[{RandomArray[NormalDistribution[0, sigmar], n], Table[Random[Real, 2\[Pi]], {n}]}]]; take a look at them In[4]:= ListPlot[t, PlotRange -> All, AspectRatio -> Automatic]; Here I may be making unwaranted assumptions that they are evenly distributed about the circle Find x0 and y0 here identified as x1 and y1 In[5]:= {x1, y1} = {Mean[First /@ t], Mean[Last /@ t]} Out[5]= {1.21852, 3.15013} using x1 and y1 convert the list to a list of radii In[6]:= rlist = Sqrt[(#[[1]] - x1)^2 + (#[[2]] - y1)^2] & /@ t; Find the mean and standard deviation of the list In[7]:= Mean[rlist] Out[7]= 3.26131 In[8]:= StandardDeviation[rlist] Out[8]= 0.444839