ϵ-density ϵ(𝒜) of the set 𝒜 ⊂ (ℝ^n)

Input: data set 𝒜 ⊂ (ℝ^n), MinPts ≥ 2;
Output: ϵ-density ϵ(𝒜);
Submodules: dM[]

EPSILON[A_,MinPts_,Fig_:0]:=Module[{yt,yy,ee,eps,slline,sleps},
yt=Table[
{A[[i]],Max[Table[Norm[Nearest[A,A[[i]],MinPts][[j]]-A[[i]]],{j,MinPts}]//N]}
,{i,Length[A]}]; 
yy=yt[[All,2]]; pp=99.;
eps=Quantile[yy,pp/100];
If[Fig≠0,ee={Quantile[yy,50/100],Quantile[yy,92/100],eps,Quantile[yy,99.5/100]};
slline=Plot[ee,{xx,0,Length[yy]},PlotStyle->{Black,Brown, Red,Orange},PlotRange->All];
sleps=Print[Show[ListPlot[yy,PlotStyle->{PointSize[.008]},PlotRange->All],slline,ImageSize->Small]]];
eps
]