(* 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[ 7830, 251] NotebookOptionsPosition[ 7468, 234] NotebookOutlinePosition[ 7816, 249] CellTagsIndexPosition[ 7773, 246] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[StyleBox["Fuzzy Rand and Jaccard indexes", FontColor->RGBColor[1, 0, 0]]], "Subsubsection", CellChangeTimes->{{3.820907236879201*^9, 3.820907243474477*^9}}, ExpressionUUID -> "fe481168-863e-40b7-987d-5ef33f6bb039"], 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[{ RowBox[{ "membership", " ", "matrices", " ", "of", " ", "partitions", " ", SuperscriptBox["\[CapitalPi]", RowBox[{"(", "1", ")"}]], " ", "and", " ", SuperscriptBox["\[CapitalPi]", RowBox[{"(", "2", ")"}]], " ", "of", " ", "the", " ", "set", " ", StyleBox["\[ScriptCapitalA]", FontSlant->"Italic"]}], StyleBox[" ", FontSlant->"Italic"], StyleBox["\[Subset]", FontSlant->"Italic"], StyleBox[" ", FontSlant->"Italic"], SuperscriptBox["\[DoubleStruckCapitalR]", "n"]}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[";", FontColor->RGBColor[0, 0, 1]]}], StyleBox[" ", 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[{ "fuzzy", " ", "Rand", " ", "FR", " ", "and", " ", "fuzzy", " ", "Jaccard", " ", "FJ", " ", "indexes"}], 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[{"none", " ", "needed"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[" ", FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]"}], "Text", CellChangeTimes->{{3.820907273780001*^9, 3.8209072967949147`*^9}, 3.8209073345018187`*^9, {3.8223153557349434`*^9, 3.8223153635902276`*^9}}, FontSize->12, ExpressionUUID -> "2a52ab5e-f8e8-449f-82b7-b27de6045ded"], Cell[BoxData[ RowBox[{ RowBox[{"RandFrigue", "[", RowBox[{"A_", ",", "B_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"m", "=", RowBox[{ RowBox[{"Dimensions", "[", "A", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", "PsiA", ",", "PsiB", ",", "a", ",", "b", ",", "c", ",", "d"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"PsiA", "=", RowBox[{"PsiB", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"i", ",", "m"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "m"}], "}"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"PsiA", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "i", "]"}], "]"}], ".", RowBox[{"A", "[", RowBox[{"[", "j", "]"}], "]"}]}]}], ";", RowBox[{ RowBox[{"PsiB", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"B", "[", RowBox[{"[", "i", "]"}], "]"}], ".", RowBox[{"B", "[", RowBox[{"[", "j", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "m"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"a", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"PsiA", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "*", RowBox[{"PsiB", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "m"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"PsiA", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "*", RowBox[{"(", RowBox[{"1", "-", RowBox[{"PsiB", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ")"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "m"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"c", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", RowBox[{"PsiA", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ")"}], "*", RowBox[{"PsiB", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "m"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"d", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", RowBox[{"PsiA", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ")"}], "*", RowBox[{"(", RowBox[{"1", "-", RowBox[{"PsiB", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ")"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"i", "+", "1"}], ",", "m"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"a", "+", "d"}], ")"}], "/", RowBox[{"(", RowBox[{"a", "+", "b", "+", "c", "+", "d"}], ")"}]}], ",", RowBox[{"a", "/", RowBox[{"(", RowBox[{"a", "+", "b", "+", "c"}], ")"}]}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", ExpressionUUID -> "bd1da35d-6170-4def-b94f-88f0b553813c"] }, 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, 231, 3, 39, "Subsubsection"], Cell[814, 27, 2012, 63, 85, "Text"], Cell[2829, 92, 4623, 139, 221, "Input"] }, Open ]] } ] *)