(* 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[ 11934, 321] NotebookOptionsPosition[ 11571, 304] NotebookOutlinePosition[ 11919, 319] CellTagsIndexPosition[ 11876, 316] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[StyleBox["Data generating from a disc", FontColor->RGBColor[1, 0, 0]]], "Subsubsection", CellChangeTimes->{{3.803475291505359*^9, 3.803475297046177*^9}, { 3.8106201267193117`*^9, 3.8106201277155557`*^9}, {3.810621211524419*^9, 3.810621216945114*^9}}, ExpressionUUID -> "21c77e07-30d7-4484-b83f-3bbaca99b2c5"], 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[{"center", " ", "C"}], " ", "\[Element]", " ", SuperscriptBox["\[DoubleStruckCapitalR]", "2"]}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"disc", " ", "radius", " ", "r"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"number", " ", SubscriptBox["n", "p"], " ", "of", " ", "points", " ", "per", " ", "unit", " ", "square"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"standard", " ", "deviation", " ", "\[Sigma]"}], FontColor->RGBColor[0, 0, 1]], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"number", " ", "nr", " ", "of", " ", "points", " ", SubscriptBox["n", "r"], " ", "generated", " ", "from"}], FontColor->RGBColor[0, 0, 1]]}], "\n", RowBox[{ StyleBox[ RowBox[{ RowBox[{ "a", " ", "normal", " ", "distribution", " ", "in", " ", "the", " ", "neighborhood", " ", "of", " ", "each", " ", "disc", " ", "point"}], ";"}], 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[{"data", " ", "set"}], FontColor->RGBColor[0, 0, 1]]}], StyleBox[",", FontColor->RGBColor[0, 0, 1]], StyleBox[" ", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"circle", " ", "K", RowBox[{"(", RowBox[{"C", ",", "r"}], ")"}]}], ";"}], FontColor->RGBColor[0, 0, 1]]}], "\[IndentingNewLine]", 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]]}]}], "Text", CellChangeTimes->{{3.8034741973219137`*^9, 3.8034748686234045`*^9}, 3.803474969583545*^9, {3.803475121933424*^9, 3.803475142349815*^9}, { 3.803475249225938*^9, 3.803475249624898*^9}, {3.8034754813321304`*^9, 3.803475718914487*^9}, {3.8036131217891645`*^9, 3.803613143148547*^9}, { 3.810614595757975*^9, 3.8106145981697664`*^9}, {3.8106212422181005`*^9, 3.810621298104375*^9}, {3.8106213305780187`*^9, 3.81062136728603*^9}, { 3.8106214649963837`*^9, 3.8106215268336134`*^9}, 3.810621617426279*^9, { 3.8106216504124146`*^9, 3.8106217273580737`*^9}, {3.8106217954319305`*^9, 3.8106217975722675`*^9}, {3.810621944867551*^9, 3.810622145353565*^9}, { 3.82229262495745*^9, 3.8222926724724445`*^9}, {3.822292724508724*^9, 3.822292776272395*^9}, {3.822305515708898*^9, 3.822305527663377*^9}}, FontSize->12, ExpressionUUID -> "f2e87e0a-da9e-4703-a0fd-5f159da9c700"], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{"DataDisc", "[", RowBox[{"S_", ",", "r_", ",", "np_", ",", "sigma_", ",", "nr_", ",", RowBox[{"Ind_:", "0"}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"Del", ",", RowBox[{"del", "=", RowBox[{".1", "r"}]}], ",", "Nr", ",", "data", ",", RowBox[{"pi", "=", RowBox[{"{", "}"}]}], ",", RowBox[{"pod", "=", RowBox[{"{", "}"}]}], ",", "Pod", ",", "circle"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"circle", "=", RowBox[{"Circle", "[", RowBox[{"S", ",", "r"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Definiranje", " ", "temeljnih", " ", "to\[CHacek]aka"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Del", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"S", "[", RowBox[{"[", "1", "]"}], "]"}], "-", "r", "-", "del"}], ",", RowBox[{ RowBox[{"S", "[", RowBox[{"[", "1", "]"}], "]"}], "+", "r", "+", "del"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"S", "[", RowBox[{"[", "2", "]"}], "]"}], "-", "r", "-", "del"}], ",", RowBox[{ RowBox[{"S", "[", RowBox[{"[", "2", "]"}], "]"}], "+", "r", "+", "del"}]}], "}"}]}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Nr", "=", RowBox[{"Floor", "[", RowBox[{"np", " ", RowBox[{"Area", "[", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Del", "[", RowBox[{"[", RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", RowBox[{"Del", "[", RowBox[{"[", RowBox[{"2", ",", "1"}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"Del", "[", RowBox[{"[", RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", RowBox[{"Del", "[", RowBox[{"[", RowBox[{"2", ",", "2"}], "]"}], "]"}]}], "}"}]}], "]"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"data", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"UniformDistribution", "[", "Del", "]"}], ",", "Nr"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"Definiranje", " ", "[", "pod", "]"}], " ", "unutar", " ", "kru\[ZHacek]nice", " ", "radijusa", " ", "r"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"data", "[", RowBox[{"[", "i", "]"}], "]"}], "-", "S"}], "]"}], "\[LessEqual]", " ", "r"}], ",", RowBox[{"pod", "=", RowBox[{"AppendTo", "[", RowBox[{"pod", ",", RowBox[{"data", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}]}]}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", "Nr"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Na", " ", "svaki", " ", RowBox[{"pod", "[", RowBox[{"[", "i", "]"}], "]"}], " ", "dodaje", " ", "se", " ", "nr", " ", "to\[CHacek]aka", " ", "iz", " ", "normalne", " ", "distribucije"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"pi", "=", RowBox[{"AppendTo", "[", RowBox[{"pi", ",", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"MultinormalDistribution", "[", RowBox[{ RowBox[{"pod", "[", RowBox[{"[", "j", "]"}], "]"}], ",", RowBox[{"sigma", " ", RowBox[{"IdentityMatrix", "[", "2", "]"}]}]}], "]"}], ",", "nr"}], "]"}]}], "]"}]}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "pod", "]"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Pod", "=", RowBox[{"Union", "[", RowBox[{"pod", ",", RowBox[{"Flatten", "[", RowBox[{"pi", ",", "1"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", "Figure", " ", "*)"}], "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"Ind", "\[NotEqual]", " ", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"slcir", "=", RowBox[{"Show", "[", RowBox[{"Graphics", "[", "circle", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"slPod", "=", RowBox[{"ListPlot", "[", RowBox[{"Pod", ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"PointSize", "[", ".005", "]"}], "}"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"Show", "[", RowBox[{"slcir", ",", "slPod", ",", RowBox[{"PlotRange", "\[Rule]", "Del"}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"Frame", "\[Rule]", "True"}], ",", RowBox[{"GridLines", "\[Rule]", "Automatic"}], ",", RowBox[{"ImageSize", "\[Rule]", "Small"}]}], "]"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"{", RowBox[{"S", ",", "r"}], "}"}], ",", "\"\<; Delta=\>\"", ",", "Del", ",", " ", "\"\<; |Pod|= \>\"", ",", RowBox[{"Length", "[", "Pod", "]"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "\t", "]"}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"Pod", ",", "circle"}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}]}]], "Input", CellChangeTimes->{{3.8034741973219137`*^9, 3.8034748686234045`*^9}, 3.803474969583545*^9, {3.803475121933424*^9, 3.803475142349815*^9}, { 3.803475249225938*^9, 3.803475249624898*^9}, {3.8034754813321304`*^9, 3.803475718914487*^9}, {3.8036131217891645`*^9, 3.803613143148547*^9}, { 3.810614595757975*^9, 3.8106145981697664`*^9}, {3.8106212422181005`*^9, 3.810621298104375*^9}, {3.8106213305780187`*^9, 3.81062136728603*^9}, { 3.8106214649963837`*^9, 3.8106215268336134`*^9}, 3.810621617426279*^9, { 3.8106216504124146`*^9, 3.8106217273580737`*^9}, {3.8106217954319305`*^9, 3.8106217975722675`*^9}, {3.810621944867551*^9, 3.810622145353565*^9}, { 3.82229262495745*^9, 3.8222926724724445`*^9}, {3.822292724508724*^9, 3.822292776272395*^9}, 3.822305515708898*^9}, ExpressionUUID -> "f2e87e0a-da9e-4703-a0fd-5f159da9c700"] }, 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, 331, 5, 39, "Subsubsection"], Cell[914, 29, 3378, 98, 87, "Text"], Cell[4295, 129, 7260, 172, 506, "Input"] }, Open ]] } ] *)