(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 12.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 8235, 227] NotebookOptionsPosition[ 7869, 210] NotebookOutlinePosition[ 8217, 225] CellTagsIndexPosition[ 8174, 222] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ StyleBox["\[Epsilon]-density \[Epsilon](\[ScriptCapitalA]) of the set ", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{"\[ScriptCapitalA]", " ", "\[Subset]", " ", SuperscriptBox["\[DoubleStruckCapitalR]", "n"]}]], CellChangeTimes->{{3.5886541897699375`*^9, 3.5886541909877396`*^9}, { 3.588654263023868*^9, 3.588654339794004*^9}, {3.5917588683674088`*^9, 3.591758869047409*^9}, {3.5917590328866577`*^9, 3.591759044816675*^9}, { 3.5937444692479725`*^9, 3.5937444771129847`*^9}, {3.8067251659311037`*^9, 3.8067252085746784`*^9}, {3.8067252462048798`*^9, 3.806725247420523*^9}, { 3.8067555742205267`*^9, 3.8067555768738213`*^9}, {3.8071002028759546`*^9, 3.807100208919777*^9}, {3.8107927170556965`*^9, 3.8107927208402033`*^9}, { 3.813128996198531*^9, 3.81312899765561*^9}, {3.8131290871131477`*^9, 3.8131291044656687`*^9}, 3.813129162727297*^9, {3.813129217851308*^9, 3.81312926039266*^9}, {3.8131293311074486`*^9, 3.813129508676306*^9}, { 3.8208235288040915`*^9, 3.8208235296679153`*^9}, {3.820823683703711*^9, 3.820823686279229*^9}}, FontColor->RGBColor[1, 0, 0], ExpressionUUID -> "3c5b9d18-0985-4523-ba3f-497a235ae468"] }], "Subsubsection", CellChangeTimes->{{3.7595897272266884`*^9, 3.759589735224825*^9}, { 3.820976958092887*^9, 3.820977018519949*^9}, {3.820977785836401*^9, 3.820977792545973*^9}}, ExpressionUUID -> "ddae7d7d-3604-45a5-bb12-3a36ad7a4d42"], Cell[BoxData[{ RowBox[{ RowBox[{ StyleBox["Input", FontColor->RGBColor[1, 0, 0]], StyleBox[":", FontColor->RGBColor[1, 0, 0]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"data", " ", "set", " ", "\[ScriptCapitalA]"}], " ", "\[Subset]", " ", SuperscriptBox["\[DoubleStruckCapitalR]", "n"]}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"MinPts", " ", "\[GreaterEqual]", " ", "2"}], ";"}], FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Output", FontColor->RGBColor[1, 0, 0]], StyleBox[":", FontColor->RGBColor[1, 0, 0]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"\[Epsilon]", "-", RowBox[{"density", " ", "\[Epsilon]", RowBox[{"(", "\[ScriptCapitalA]", ")"}]}]}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[";", FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["Submodules", FontColor->RGBColor[1, 0, 0]], StyleBox[":", FontColor->RGBColor[1, 0, 0]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"dM", "[", "]"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[" ", FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]"}], "Text", CellChangeTimes->{{3.8209778228824396`*^9, 3.8209778718310347`*^9}, { 3.8223074543064017`*^9, 3.8223074620496783`*^9}}, FontSize->12, ExpressionUUID -> "29e56ac3-3e31-49af-8698-19b57305572e"], Cell[BoxData[ RowBox[{ RowBox[{"EPSILON", "[", RowBox[{"A_", ",", "MinPts_", ",", RowBox[{"Fig_:", "0"}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "yt", ",", "yy", ",", "ee", ",", "eps", ",", "slline", ",", "sleps"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"yt", "=", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"Max", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{ RowBox[{"Nearest", "[", RowBox[{"A", ",", RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "MinPts"}], "]"}], "[", RowBox[{"[", "j", "]"}], "]"}], "-", RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "MinPts"}], "}"}]}], "]"}], "//", "N"}], "]"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "A", "]"}]}], "}"}]}], "]"}]}], ";", " ", "\[IndentingNewLine]", RowBox[{"yy", "=", RowBox[{"yt", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", " ", RowBox[{"pp", "=", "99."}], ";", "\[IndentingNewLine]", RowBox[{"eps", "=", RowBox[{"Quantile", "[", RowBox[{"yy", ",", RowBox[{"pp", "/", "100"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"Fig", "\[NotEqual]", "0"}], ",", RowBox[{ RowBox[{"ee", "=", RowBox[{"{", RowBox[{ RowBox[{"Quantile", "[", RowBox[{"yy", ",", RowBox[{"50", "/", "100"}]}], "]"}], ",", RowBox[{"Quantile", "[", RowBox[{"yy", ",", RowBox[{"92", "/", "100"}]}], "]"}], ",", "eps", ",", RowBox[{"Quantile", "[", RowBox[{"yy", ",", RowBox[{"99.5", "/", "100"}]}], "]"}]}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"slline", "=", RowBox[{"Plot", "[", RowBox[{"ee", ",", RowBox[{"{", RowBox[{"xx", ",", "0", ",", RowBox[{"Length", "[", "yy", "]"}]}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"Black", ",", "Brown", ",", " ", "Red", ",", "Orange"}], "}"}]}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sleps", "=", RowBox[{"Print", "[", RowBox[{"Show", "[", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{"yy", ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"PointSize", "[", ".008", "]"}], "}"}]}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}], ",", "slline", ",", RowBox[{"ImageSize", "\[Rule]", "Small"}]}], "]"}], "]"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", "eps"}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{ 3.803996839606488*^9, {3.803996880772684*^9, 3.8039968845324955`*^9}, { 3.8039969452880983`*^9, 3.80399702877054*^9}, {3.8039971384832907`*^9, 3.8039971657781754`*^9}, {3.8039973434261513`*^9, 3.8039973955631742`*^9}, {3.8039978149885945`*^9, 3.8039978308141346`*^9}, {3.803997891097745*^9, 3.8039978986620502`*^9}, 3.803998710932787*^9, 3.8040429994092426`*^9, {3.804044930910961*^9, 3.8040449459228907`*^9}, {3.8160917040603385`*^9, 3.816091704838705*^9}, 3.8161384055929213`*^9, 3.820976829788107*^9, {3.8209778950283732`*^9, 3.820977904137167*^9}}, ExpressionUUID -> "ca9aeaa2-e00c-4dd3-805f-a38345e7e09e"] }, Open ]] }, WindowSize->{1536, 779}, WindowMargins->{{-8, Automatic}, {Automatic, -8}}, FrontEndVersion->"11.0 for Microsoft Windows (64-bit) (September 21, 2016)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 1454, 24, 39, "Subsubsection"], Cell[2037, 48, 1650, 54, 83, "Text"], Cell[3690, 104, 4163, 103, 221, "Input"] }, Open ]] } ] *)