My attempted solution
Remark: this is not the correct answer but it seems to be a good
approximation to the truth - and it is very simple.
The main idea is "center of mass".
Step 1: calculate the center of mass. This will be the center of the circle
Step 2: determine the maximum difference of all points to the center of
mass: this will be the radius of the circle
Create sample data (e.g. normally distributed around the
origin)
In[27]:=
<< "Statistics`ContinuousDistributions`"
In[140]:=
pp = NormalDistribution[0, 1];
In[142]:=
n = 10;
px = RandomArray[NormalDistribution[0, 1], n];
py = RandomArray[NormalDistribution[0, 1], n];
points = Transpose[{px, py}];
Calculate location of center of mass ...
In[146]:=
c = {Mean[px], Mean[py]}
Out[146]=
{0.2679039580402966, -0.10697128218318264}
... and r as the maximum distance to the center
In[147]:=
dif = ((c - #1) . (c - #1) & ) /@ points;
In[154]:=
r = Sqrt[Max[dif]]
Out[154]=
1.5977195212803568
Show points and circle
In[155]:=
Show[{grpoints, Graphics[Circle[c, r]]},
DisplayFunction -> $DisplayFunction,
AspectRatio -> Automatic];
Looks quite nice. But isn't correct as usually the circle could be a bit
smaller, as can be seen by the naked eye.
Regards,
Wolfgang
Steve Gray wrote:
> Given n points in the plane, I want to find the smallest
> enclosing circle. Does anyone have Mathematica code to do this?
> I will be grateful for any tips.
>
> Steve Gray
>
>