(* 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[ 27683, 766] NotebookOptionsPosition[ 27315, 749] NotebookOutlinePosition[ 27663, 764] CellTagsIndexPosition[ 27620, 761] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ StyleBox["K - Means algoritam for the data set \[ScriptCapitalA] \[Subset] \ \[DoubleStruckCapitalR] , or ", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{"\[ScriptCapitalA]", " ", "\[Subset]", " ", SuperscriptBox["\[DoubleStruckCapitalR]", "2"]}]], FontColor->RGBColor[1, 0, 0], ExpressionUUID -> "c32008ac-184c-4461-94bb-5ee4feee0e74"], StyleBox[" started with an initial centers", FontColor->RGBColor[1, 0, 0]] }], "Subsubsection", CellChangeTimes->{{3.7311282758576365`*^9, 3.7311283023292036`*^9}, { 3.8209848930172358`*^9, 3.820984956217693*^9}, {3.8209856844205265`*^9, 3.8209856863817496`*^9}}, ExpressionUUID -> "84ab69d5-84d3-4f3a-9e89-4809531361bd"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{ StyleBox["Input", FontColor->RGBColor[1, 0, 0]], StyleBox[":", FontColor->RGBColor[1, 0, 0]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"data", " ", "set", " ", "\[ScriptCapitalA]"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"initial", " ", "centers", " ", SubscriptBox["z", "1"]}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox["\[TripleDot]", FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[ SubscriptBox["z", "k"], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], RowBox[{ StyleBox[ RowBox[{"parameter", " ", StyleBox["p", FontSlant->"Italic"]}], FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox["=", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], RowBox[{ StyleBox["1", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox["or", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ StyleBox["2", FontSlant->"Italic", FontColor->RGBColor[0, 0, 1]], StyleBox[".", FontColor->RGBColor[0, 0, 1]]}]]}]}]}], StyleBox[" ", FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]", StyleBox[ RowBox[{ RowBox[{ RowBox[{"One", " ", "can", " ", "choose", " ", "the", " ", StyleBox["p", FontSlant->"Italic"]}], "-", RowBox[{"distance", " ", "like", " ", "function", " ", "for", " ", StyleBox["p", FontSlant->"Italic"]}]}], StyleBox[" ", FontSlant->"Italic"], StyleBox["=", FontSlant->"Italic"], StyleBox[" ", FontSlant->"Italic"], RowBox[{ StyleBox["1", FontSlant->"Italic"], StyleBox[" ", FontSlant->"Italic"], StyleBox["or", FontSlant->"Italic"], StyleBox[" ", FontSlant->"Italic"], StyleBox[ RowBox[{ StyleBox["2", FontSlant->"Italic"], "."}]], " ", "Options"}]}], FontColor->RGBColor[0, 0, 1]], "\n", RowBox[{ StyleBox["\t", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ "for", " ", "printout", " ", "and", " ", "graphical", " ", "presentation", " ", "of", " ", "intermediate"}], FontColor->RGBColor[0, 0, 1]]}], "\n", RowBox[{ StyleBox["\t", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"results", " ", "are", " ", "provided", " ", RowBox[{"(", StyleBox[ RowBox[{"Ind", "=", "1"}], FontSlant->"Italic"], ")"}]}], ",", " ", RowBox[{ "as", " ", "well", " ", "as", " ", "options", " ", "for", " ", "printing", " ", "the"}]}], FontColor->RGBColor[0, 0, 1]]}], "\n", RowBox[{ StyleBox["\t", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ "results", " ", "as", " ", "fractions", " ", "or", " ", "as", " ", "decimal", " ", "numbers", " ", RowBox[{"(", RowBox[{"num", "=", "1"}], ")"}]}], ";"}], FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]", RowBox[{ StyleBox["\t", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ RowBox[{"Examples", " ", "from", " ", "Test"}], "-", RowBox[{ "example", " ", "9.1", " ", "can", " ", "also", " ", "be", " ", "used"}]}], ";"}], 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[{"partition", " ", "\[CapitalPi]"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"centers", " ", SubscriptBox["c", "1"]}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox["\[TripleDot]", FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[ SubscriptBox["c", "k"], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ "objective", " ", "function", " ", "values", " ", "\[ScriptCapitalF]", RowBox[{"(", "\[CapitalPi]", ")"}]}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"\[FormalCapitalF]", RowBox[{"(", "c", ")"}]}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox["\t", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"or", " ", "\[ScriptCapitalG]", RowBox[{"(", "\[CapitalPi]", ")"}]}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ "values", " ", "of", " ", "CH", " ", "index", " ", "and", " ", "DB", " ", "index"}], ";"}], FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ StyleBox["Submodules", FontColor->RGBColor[1, 0, 0]], StyleBox[":", FontColor->RGBColor[1, 0, 0]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"d", "[", "]"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"FF", "[", "]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"Fmin", "[", "]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"Figure1", "[", "]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"Figure2", "[", "]"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[" ", FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]"}], "Text", CellChangeTimes->{{3.8209850103247423`*^9, 3.8209850890189104`*^9}, { 3.8209851240124426`*^9, 3.8209852077723737`*^9}, 3.8209853390670557`*^9, { 3.820985415926425*^9, 3.8209854412654853`*^9}, {3.8209855014622383`*^9, 3.8209856033477964`*^9}, {3.8209857176918616`*^9, 3.8209857709951153`*^9}, {3.822311107072241*^9, 3.8223111250657883`*^9}}, FontSize->12, ExpressionUUID -> "8952ba7a-5746-4ee6-ab7b-6edf5bd275e2"], Cell[BoxData[ RowBox[{ RowBox[{"KMeansCen", "[", RowBox[{"A_", ",", "z_", ",", RowBox[{"p_:", "2"}], ",", RowBox[{"Ind_:", "1"}], ",", RowBox[{"num_:", "1"}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"m", "=", RowBox[{"Length", "[", "A", "]"}]}], ",", RowBox[{"k", "=", RowBox[{"k0", "=", RowBox[{"Length", "[", "z", "]"}]}]}], ",", RowBox[{"it", "=", "1"}], ",", "F0", ",", "F1", ",", "G", ",", "PI", ",", "tab", ",", "imin", ",", "c", ",", "sigma2", ",", "KK", ",", "CH", ",", "DB"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"PI", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ RowBox[{"it", "-", "1"}], ",", "\"\<: A=\>\"", ",", "A", ",", "\"\<; z=\>\"", ",", "z", ",", "\"\<; Fmin=\>\"", ",", RowBox[{"Fmin", "[", RowBox[{"A", ",", "z", ",", "p"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Figure1", "[", RowBox[{"{", "A", "}"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"tab", "=", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"d", "[", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"z", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "p"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}], "//", "N"}]}], ";", "\[IndentingNewLine]", RowBox[{"imin", "=", RowBox[{ RowBox[{"Ordering", "[", RowBox[{"tab", ",", "1"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"PI", "[", RowBox[{"[", "imin", "]"}], "]"}], "=", RowBox[{"Append", "[", RowBox[{ RowBox[{"PI", "[", RowBox[{"[", "imin", "]"}], "]"}], ",", RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "m"}], "}"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"PI", "=", RowBox[{"DeleteCases", "[", RowBox[{"PI", ",", RowBox[{"{", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"k", "=", RowBox[{"Length", "[", "PI", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"k", "<", RowBox[{"Length", "[", "z", "]"}]}], ",", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "k0"}], "]"}], ",", "\"\< to \>\"", ",", "k"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"p", "\[Equal]", "2"}], ",", RowBox[{ RowBox[{"c", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Mean", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", " ", RowBox[{"G", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"c", "[", RowBox[{"[", "j", "]"}], "]"}], "-", RowBox[{"Mean", "[", "A", "]"}]}], "]"}], "^", "2"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}]}], ",", RowBox[{ RowBox[{"c", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Median", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", RowBox[{"G", "=", RowBox[{"{", "}"}]}], ";"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"num", "\[Equal]", "1"}], ",", RowBox[{ RowBox[{"c", "=", RowBox[{"c", "//", "N"}]}], ";", RowBox[{"G", "=", RowBox[{"G", "//", "N"}]}]}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "it", ",", "\"\<: PI=\>\"", ",", "PI", ",", "\"\<; c=\>\"", ",", "c", ",", "\"\<; F=\>\"", ",", RowBox[{"F0", "=", RowBox[{"FF", "[", RowBox[{"PI", ",", "c", ",", "p"}], "]"}]}], ",", "\"\<; G=\>\"", ",", "G", ",", "\"\<; Fmin=\>\"", ",", RowBox[{"Fmin", "[", RowBox[{"A", ",", "c", ",", "p"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", RowBox[{"A", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{"Figure1", "[", "PI", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", RowBox[{"A", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}], "\[Equal]", "2"}], ",", RowBox[{"Figure2", "[", "PI", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"PI", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"tab", "=", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"d", "[", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"c", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "p"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}], "//", "N"}]}], ";", "\[IndentingNewLine]", RowBox[{"imin", "=", RowBox[{ RowBox[{"Ordering", "[", RowBox[{"tab", ",", "1"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"PI", "[", RowBox[{"[", "imin", "]"}], "]"}], "=", RowBox[{"Append", "[", RowBox[{ RowBox[{"PI", "[", RowBox[{"[", "imin", "]"}], "]"}], ",", RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "m"}], "}"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"PI", "=", RowBox[{"DeleteCases", "[", RowBox[{"PI", ",", RowBox[{"{", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"k", "=", RowBox[{"Length", "[", "PI", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"k", "<", "k0"}], ",", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "k0"}], "]"}], ",", "\"\< na \>\"", ",", "k"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"p", "\[Equal]", "2"}], ",", RowBox[{ RowBox[{"c", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Mean", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", " ", RowBox[{"G", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"c", "[", RowBox[{"[", "j", "]"}], "]"}], "-", RowBox[{"Mean", "[", "A", "]"}]}], "]"}], "^", "2"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}]}], ",", RowBox[{ RowBox[{"c", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Median", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", RowBox[{"G", "=", RowBox[{"{", "}"}]}], ";"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"num", "\[Equal]", "1"}], ",", RowBox[{ RowBox[{"c", "=", RowBox[{"c", "//", "N"}]}], ";", RowBox[{"G", "=", RowBox[{"G", "//", "N"}]}]}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"F1", "=", RowBox[{"FF", "[", RowBox[{"PI", ",", "c", ",", "p"}], "]"}]}], ";", RowBox[{"it", "=", RowBox[{"it", "+", "1"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "it", ",", "\"\<: PI=\>\"", ",", "PI", ",", "\"\<; c=\>\"", ",", "c", ",", "\"\<; F=\>\"", ",", "F1", ",", "\"\<; G=\>\"", ",", "G", ",", "\"\<; Fmin=\>\"", ",", RowBox[{"Fmin", "[", RowBox[{"A", ",", "c", ",", "p"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"Chop", "[", RowBox[{"F0", "-", "F1"}], "]"}], "\[NotEqual]", "0"}]}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", RowBox[{"A", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{"Figure1", "[", "PI", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", RowBox[{"A", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}], "\[Equal]", "2"}], ",", RowBox[{"Figure2", "[", "PI", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"F0", "=", "F1"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"p", "\[Equal]", "2"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"CH", "=", RowBox[{ RowBox[{"(", RowBox[{"G", "/", RowBox[{"(", RowBox[{"k", "-", "1"}], ")"}]}], ")"}], "/", RowBox[{"(", RowBox[{"F1", "/", RowBox[{"(", RowBox[{"m", "-", "k"}], ")"}]}], ")"}]}]}], ";", RowBox[{"Print", "[", RowBox[{ RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Red", ",", "18"}], "]"}], ",", "\"\<(\>\"", ",", "k", ",", "\"\<) = \>\"", ",", RowBox[{"Style", "[", RowBox[{"CH", ",", "Red", ",", "18"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"KK", "=", RowBox[{"Table", "[", RowBox[{"j", ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sigma2", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"c", "[", RowBox[{"[", "j", "]"}], "]"}], "-", RowBox[{"PI", "[", RowBox[{"[", RowBox[{"j", ",", "s"}], "]"}], "]"}]}], "]"}], "^", "2"}], ",", RowBox[{"{", RowBox[{"s", ",", RowBox[{"Length", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}]}], "}"}]}], "]"}], "/", RowBox[{"Length", "[", RowBox[{"PI", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "c"}], "]"}], ";", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"Sqrt", "[", "sigma2", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"DB", "=", RowBox[{ RowBox[{"Sum", "[", RowBox[{ RowBox[{"Max", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Sqrt", "[", RowBox[{"sigma2", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], "+", RowBox[{"Sqrt", "[", RowBox[{"sigma2", "[", RowBox[{"[", "s", "]"}], "]"}], "]"}]}], ")"}], "/", RowBox[{"Norm", "[", RowBox[{ RowBox[{"c", "[", RowBox[{"[", "j", "]"}], "]"}], "-", RowBox[{"c", "[", RowBox[{"[", "s", "]"}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"s", ",", RowBox[{"Complement", "[", RowBox[{"KK", ",", RowBox[{"{", "j", "}"}]}], "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "k"}], "}"}]}], "]"}], "/", "k"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ RowBox[{"Style", "[", RowBox[{"\"\\"", ",", "Blue", ",", "18"}], "]"}], ",", "\"\<(\>\"", ",", "k", ",", "\"\<) = \>\"", ",", RowBox[{"Style", "[", RowBox[{"DB", ",", "Blue", ",", "18"}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"PI", ",", "c", ",", "F1", ",", "G", ",", "CH", ",", "DB"}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.73112578295751*^9, 3.731125956992042*^9}, { 3.731125987088831*^9, 3.7311261640768085`*^9}, {3.7311261955646596`*^9, 3.73112623044333*^9}, {3.7311263770214214`*^9, 3.731126492096473*^9}, { 3.731126547961833*^9, 3.7311265593222837`*^9}, {3.731126597467252*^9, 3.7311267040567617`*^9}, {3.7311272921927633`*^9, 3.7311273243680735`*^9}, {3.731127420206789*^9, 3.731127434848837*^9}, { 3.7311275105443754`*^9, 3.731127510935127*^9}, {3.731127699861579*^9, 3.7311277217702236`*^9}, {3.731127829219427*^9, 3.7311278492998037`*^9}, { 3.731127880865615*^9, 3.731127936512225*^9}, {3.731131571811527*^9, 3.7311316164723024`*^9}, {3.763901581369135*^9, 3.7639015835092983`*^9}, { 3.7639016704264383`*^9, 3.763901671707561*^9}, {3.7639027241345005`*^9, 3.7639027535340395`*^9}, {3.763902838248406*^9, 3.7639028451998663`*^9}, { 3.763902905138945*^9, 3.7639029160270553`*^9}, {3.7639042326574206`*^9, 3.763904254277369*^9}, {3.7639043646731806`*^9, 3.7639043792480907`*^9}, { 3.7639044452011967`*^9, 3.763904456573577*^9}, {3.7639047207929125`*^9, 3.7639047228705416`*^9}, {3.76390478254426*^9, 3.7639047949788527`*^9}, { 3.763904837171941*^9, 3.763904844764076*^9}, {3.7639051670478115`*^9, 3.7639051965254374`*^9}, {3.7639052279555798`*^9, 3.763905251896916*^9}, { 3.7639053597308664`*^9, 3.7639053632458334`*^9}, {3.7639914771111298`*^9, 3.763991477427286*^9}, {3.7639915086866865`*^9, 3.763991513397133*^9}, { 3.763991632016856*^9, 3.763991635681072*^9}, {3.7639919920253816`*^9, 3.7639920039863873`*^9}, {3.7639921261307783`*^9, 3.7639921263033085`*^9}, {3.763992158930053*^9, 3.763992191909856*^9}, 3.763992381287408*^9, {3.7639935386160736`*^9, 3.763993538961115*^9}, { 3.7639935747065563`*^9, 3.763993575415618*^9}, {3.763996028533924*^9, 3.763996029418552*^9}, {3.7639962288839397`*^9, 3.763996269422522*^9}, 3.7639963866500177`*^9, 3.7639964352271175`*^9, {3.7639964655190983`*^9, 3.763996519556587*^9}, 3.763996688048981*^9, {3.7639967387983027`*^9, 3.763996740157669*^9}, {3.76399728085767*^9, 3.763997293326316*^9}, { 3.7639973427312193`*^9, 3.76399743842332*^9}, {3.7639974706281614`*^9, 3.7639974916629033`*^9}, {3.7639975884570494`*^9, 3.763997639826666*^9}, { 3.7639976965888653`*^9, 3.7639977298838673`*^9}, {3.763997776324625*^9, 3.7639977989491634`*^9}, {3.763998277619008*^9, 3.763998316508494*^9}, 3.7640795701931515`*^9, {3.7640799311219893`*^9, 3.7640799549692125`*^9}, { 3.7644227271808605`*^9, 3.764422734226041*^9}, 3.7644258940901537`*^9, { 3.7644259298787994`*^9, 3.7644259313782763`*^9}, 3.7654486314938974`*^9, 3.765944775838312*^9, {3.7659448658178043`*^9, 3.7659449515676403`*^9}, { 3.7659450412907887`*^9, 3.7659450575772552`*^9}, {3.7659451063170204`*^9, 3.765945108412388*^9}, {3.766929492509037*^9, 3.7669295499043293`*^9}, { 3.76692958168688*^9, 3.766929592947941*^9}, {3.766929794850202*^9, 3.7669298326732264`*^9}, {3.766929866785038*^9, 3.7669298834958467`*^9}, { 3.7989512069360003`*^9, 3.798951233950181*^9}, {3.8070804950888042`*^9, 3.8070805175192804`*^9}, {3.8071025377195168`*^9, 3.8071025379763393`*^9}, {3.807103532910446*^9, 3.807103533346631*^9}, { 3.8107006972001657`*^9, 3.810700746374124*^9}, {3.8209860008119235`*^9, 3.8209860199245124`*^9}},ExpressionUUID->"d9296126-f3ed-4e80-8e91-\ eeeb632781b5"] }, 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, 710, 15, 39, "Subsubsection"], Cell[1293, 39, 7382, 257, 193, "Text"], Cell[8678, 298, 18621, 448, 848, "Input"] }, Open ]] } ] *)