(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.2' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 38347, 1091] NotebookOptionsPosition[ 32281, 1001] NotebookOutlinePosition[ 32879, 1023] CellTagsIndexPosition[ 32836, 1020] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Introduction to ", StyleBox["Mathematica", FontSlant->"Italic"] }], "Title", CellChangeTimes->{{3.6826618323093286`*^9, 3.6826618413622*^9}},ExpressionUUID->"14802d20-6a07-4097-ae91-10cedbe0d82c"], Cell["Vito, 30/3/2023", "Text", CellChangeTimes->{{3.6672243733267775`*^9, 3.667224375881893*^9}, { 3.6826618481520457`*^9, 3.682661854066499*^9}, {3.69990165468799*^9, 3.6999016572877417`*^9}, {3.8896972166844287`*^9, 3.8896972198755445`*^9}},ExpressionUUID->"c8e22209-a261-4e89-b290-\ 2cf8854656d6"], Cell[CellGroupData[{ Cell["Hidding variables", "Section", CellChangeTimes->{{3.6826618807430964`*^9, 3.6826618945023603`*^9}},ExpressionUUID->"6d51b5d4-c182-4e11-9e6f-\ 01ad34f891e8"], Cell["\<\ There are a few constructs to hide the variables in a function and/or avoid \ propagating local changes to the global namespace. We will see the Module[ ] \ construct, very akin to functions in C or Fortran. Later we will see how to \ define another namespace, with the Package construction. We will not discuss \ neither Block[ ] nor With[ ], which are complementary to Module[ ], but that \ happen less often in practice.\ \>", "Text", CellChangeTimes->{{3.6826619042062283`*^9, 3.682662124540331*^9}, { 3.68266247031424*^9, 3.6826626418439107`*^9}, {3.6999048138072214`*^9, 3.699904824483035*^9}, {3.6999048718912964`*^9, 3.6999048768418818`*^9}},ExpressionUUID->"b90ef096-c856-4058-a809-\ 5c42d07980fa"], Cell[CellGroupData[{ Cell["\<\ Comparing the performance of different location estimators of the mean\ \>", "Subsection", CellChangeTimes->{{3.6826626959104385`*^9, 3.682662738977086*^9}},ExpressionUUID->"a0bd7381-7ab6-41a8-bc10-\ 586c6a4f61cc"], Cell[BoxData[ RowBox[{ RowBox[{"x0", "=", "20"}], ";", RowBox[{"\[Sigma]0", "=", "3"}], ";"}]], "Input", CellChangeTimes->{{3.6826627627276587`*^9, 3.682662783377694*^9}},ExpressionUUID->"aabef32e-eae1-46b3-935a-\ cc58d93f5e3e"], Cell[BoxData[ RowBox[{ RowBox[{"u", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"x0", ",", "\[Sigma]0"}], "]"}], ",", "100"}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.6826627986305714`*^9, 3.682662801413988*^9}},ExpressionUUID->"a1af20bb-47e0-499d-b08f-\ 2278e503b342"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"Mean", "[", "u", "]"}], ",", RowBox[{"Median", "[", "u", "]"}], ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Max", "[", "u", "]"}], "+", RowBox[{"Min", "[", "u", "]"}]}], ")"}], "/", "2"}]}], "}"}]], "Input", CellChangeTimes->{{3.682662809545164*^9, 3.6826628416252265`*^9}, { 3.6826628958203588`*^9, 3.6826629137404313`*^9}},ExpressionUUID->"58fdad53-9f0c-4078-a4ce-\ 46c607e4fa82"], Cell[BoxData[ RowBox[{ RowBox[{"location", "[", RowBox[{"x0_", ",", "\[Sigma]0_", ",", "n_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "u", "}"}], ",", RowBox[{ RowBox[{"u", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"x0", ",", "\[Sigma]0"}], "]"}], ",", "n"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Mean", "[", "u", "]"}], ",", RowBox[{"StandardDeviation", "[", "u", "]"}], ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Max", "[", "u", "]"}], "+", RowBox[{"Min", "[", "u", "]"}]}], ")"}], "/", "2"}]}], "}"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.6826629578224087`*^9, 3.6826630114041305`*^9}},ExpressionUUID->"99dffea6-e58b-44ed-80be-\ dc20dfd2f1eb"], Cell[BoxData[ RowBox[{ RowBox[{"v", "=", RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"location", "[", RowBox[{"20", ",", "3", ",", "10"}], "]"}], ",", RowBox[{"{", "1000", "}"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.6826630384469624`*^9, 3.682663088792184*^9}},ExpressionUUID->"2be23d5b-da38-4626-b871-\ 594c543bd2a0"], Cell[BoxData[ RowBox[{"StandardDeviation", "[", "v", "]"}]], "Input", CellChangeTimes->{{3.682663092645759*^9, 3.682663097395814*^9}},ExpressionUUID->"e25201de-b2d5-448a-b046-\ 8079c582cf10"], Cell[BoxData[ RowBox[{ RowBox[{"simulation", "[", RowBox[{"n_", ",", "histories_"}], "]"}], ":=", RowBox[{"StandardDeviation", "[", RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"location", "[", RowBox[{"20", ",", "3", ",", "n"}], "]"}], ",", RowBox[{"{", "histories", "}"}]}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.682663121182764*^9, 3.68266320021719*^9}},ExpressionUUID->"1d915d6f-d379-43b3-990a-\ 77b542a8e8ae"], Cell[BoxData[ RowBox[{"simulation", "[", RowBox[{"10", ",", "1000"}], "]"}]], "Input", CellChangeTimes->{{3.682663212535431*^9, 3.6826632240743704`*^9}},ExpressionUUID->"cc3790c6-4125-46ff-b6a5-\ 1971893214ec"], Cell[BoxData[ RowBox[{"low", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"{", RowBox[{"n", ",", RowBox[{"simulation", "[", RowBox[{"n", ",", "1000"}], "]"}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "2", ",", "30"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.682663232689118*^9, 3.682663271568513*^9}, { 3.68266330398036*^9, 3.6826633404186835`*^9}},ExpressionUUID->"f75d95ce-7d94-4833-a370-\ c225ab224106"], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{"{", RowBox[{ RowBox[{"low", "[", RowBox[{"[", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "2"}], "}"}]}], "]"}], "]"}], " ", ",", RowBox[{"low", "[", RowBox[{"[", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "3"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"low", "[", RowBox[{"[", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "4"}], "}"}]}], "]"}], "]"}]}], "}"}], "]"}]], "Input", CellChangeTimes->{{3.6826633451224775`*^9, 3.682663387930354*^9}},ExpressionUUID->"e8945ecd-fb7c-4d05-898a-\ bf0126706c15"], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"low", "[", RowBox[{"[", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "i"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "2", ",", "4"}], "}"}]}], "]"}], " ", "]"}]], "Input", CellChangeTimes->{{3.6826633978799*^9, 3.682663452439571*^9}, { 3.6826634938836055`*^9, 3.6826634962996006`*^9}},ExpressionUUID->"d6359948-7767-481f-8ca5-\ 792c28bef9eb"], Cell[BoxData[ RowBox[{"high", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"{", RowBox[{"n", ",", RowBox[{"simulation", "[", RowBox[{"n", ",", "1000"}], "]"}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "10", ",", "300", ",", "10"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.682663519270293*^9, 3.6826635560894575`*^9}},ExpressionUUID->"7789d311-11fe-4b43-97bd-\ 306d960fb8e9"], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"high", "[", RowBox[{"[", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "i"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "2", ",", "4"}], "}"}]}], "]"}], " ", "]"}]], "Input", CellChangeTimes->{{3.6826635622970886`*^9, 3.682663563182428*^9}},ExpressionUUID->"8cd58b5b-846b-4689-88b2-\ 35716618d749"] }, Open ]], Cell[CellGroupData[{ Cell["Rules", "Subsection", CellChangeTimes->{{3.682664023859974*^9, 3.6826640254125404`*^9}},ExpressionUUID->"011c5b25-bbae-4ca4-a1e0-\ 2bb084b6fe66"], Cell["\<\ Many functions return their results as Rules. We need to learn to pick the \ desired answer, using the operator ReplaceAll, /.\ \>", "Text", CellChangeTimes->{{3.68266407985666*^9, 3.6826641229914036`*^9}, { 3.6826642881972027`*^9, 3.6826643224915733`*^9}},ExpressionUUID->"f4567fb2-4424-4682-a4e7-\ 8ecc0177a1d1"], Cell[BoxData[ RowBox[{"solution", "=", RowBox[{"Solve", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"x", "^", "4"}], "-", RowBox[{"2", RowBox[{"x", "^", "3"}]}], "-", RowBox[{"13", RowBox[{"x", "^", "2"}]}], "+", RowBox[{"14", "x"}], "+", "24"}], "\[Equal]", "0"}], ",", "x"}], "]"}]}]], "Input", CellChangeTimes->{{3.682664161255598*^9, 3.682664240865622*^9}},ExpressionUUID->"6fa9a732-eebf-4250-b57f-\ 8737ddf76e8b"], Cell[BoxData[ RowBox[{"solution", "[", RowBox[{"[", "1", "]"}], "]"}]], "Input", CellChangeTimes->{{3.6826642440709553`*^9, 3.6826642462354712`*^9}},ExpressionUUID->"8063734f-667b-4fb6-92dc-\ 47e1067ce7d7"], Cell[BoxData[ RowBox[{"x", "/.", RowBox[{"solution", "[", RowBox[{"[", "1", "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.682664254695903*^9, 3.6826642651450195`*^9}},ExpressionUUID->"aa7fab7e-3939-4b96-956b-\ c048619878a8"], Cell[BoxData[ RowBox[{"a", "=", RowBox[{"x", "/.", RowBox[{"solution", "[", RowBox[{"[", "2", "]"}], "]"}]}]}]], "Input", CellChangeTimes->{{3.682664268047778*^9, 3.6826642733539734`*^9}, { 3.6826643626963987`*^9, 3.682664363143454*^9}},ExpressionUUID->"1b98be5f-8b91-4825-8635-\ 8e4e5ae623ad"], Cell[BoxData[ RowBox[{"v", "=", RowBox[{"x", "/.", "solution"}]}]], "Input", CellChangeTimes->{{3.682664280859592*^9, 3.6826642833816776`*^9}, { 3.682664329205744*^9, 3.682664335709654*^9}},ExpressionUUID->"1a76b739-39ad-473e-becf-\ ef4d3a7c3f45"], Cell[BoxData[ RowBox[{"v", "[", RowBox[{"[", "1", "]"}], "]"}]], "Input", CellChangeTimes->{{3.682664342428404*^9, 3.682664345475317*^9}},ExpressionUUID->"ad94346b-2b8c-4f5b-ab86-\ 4deb9d19a568"], Cell[BoxData[ RowBox[{"Clear", "[", RowBox[{"x", ",", "x0", ",", "\[Omega]"}], "]"}]], "Input", CellChangeTimes->{{3.682664475480867*^9, 3.682664477137368*^9}, { 3.6826646241335783`*^9, 3.6826646248642316`*^9}, {3.682664851868271*^9, 3.682664854434967*^9}},ExpressionUUID->"cfcc61af-36ec-4041-b200-\ e05940c4ffc5"], Cell[BoxData[ RowBox[{"funcRule", "=", RowBox[{"DSolve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"x", "''"}], "[", "t", "]"}], "+", RowBox[{ RowBox[{"\[Omega]", "^", "2"}], " ", RowBox[{"x", "[", "t", "]"}]}]}], "\[Equal]", "0"}], ",", " ", RowBox[{ RowBox[{ RowBox[{"x", "'"}], "[", "0", "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"x", "[", "0", "]"}], "\[Equal]", "x0"}]}], "}"}], ",", RowBox[{"x", "[", "t", "]"}], ",", "t", ",", RowBox[{"Assumptions", "\[Rule]", RowBox[{"\[Omega]", ">", "0"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.6826643965287075`*^9, 3.6826644719101534`*^9}, { 3.682664523711181*^9, 3.6826645666877117`*^9}, {3.6826646187017145`*^9, 3.6826646467011995`*^9}},ExpressionUUID->"55b2e24f-f183-4aa7-a31b-\ e877ad0e5c87"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "funcRule"}], "/.", RowBox[{"{", RowBox[{ RowBox[{"x0", "\[Rule]", "10"}], ",", RowBox[{"\[Omega]", "->", RowBox[{"1", "/", "10"}]}]}], "}"}]}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "20"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.682664681759616*^9, 3.6826647778967257`*^9}, { 3.6826648166741705`*^9, 3.682664820422258*^9}},ExpressionUUID->"090aa0c0-10d2-43a3-a48d-\ b21219097512"], Cell[BoxData[ RowBox[{"func", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", "funcRule"}], ")"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.682664866824902*^9, 3.6826648959605565`*^9}},ExpressionUUID->"b290f6fc-d006-4d66-8d77-\ afc4b57c3f65"], Cell[BoxData[ RowBox[{ RowBox[{"x", "[", "t", "]"}], "/.", RowBox[{"funcRule", "[", RowBox[{"[", "1", "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.6826649380306883`*^9, 3.682664948286121*^9}},ExpressionUUID->"4fc0047d-2cc6-480e-af8b-\ bb32de107be7"] }, Open ]], Cell["Interactive objects", "Subsection", CellChangeTimes->{{3.682665732796682*^9, 3.6826657372341237`*^9}},ExpressionUUID->"ae8dcd8f-2423-4f94-9ed3-\ f3d64df7b89b"], Cell[CellGroupData[{ Cell["How the normal Limit is approached", "Subsection", CellChangeTimes->{{3.6826657633814993`*^9, 3.6826657889353676`*^9}},ExpressionUUID->"5b89e2d2-48ce-4823-9d1a-\ f7062319466c"], Cell[BoxData[ RowBox[{"d", "=", RowBox[{"RandomVariate", "[", " ", RowBox[{ RowBox[{"ChiSquareDistribution", "[", "5", "]"}], ",", "10"}], "]"}]}]], "Input", CellChangeTimes->{{3.68266579563422*^9, 3.6826658197022343`*^9}},ExpressionUUID->"16f9764e-5d24-4807-967f-\ ec359b1518d9"], Cell[BoxData[ RowBox[{"Mean", "[", "d", "]"}]], "Input", CellChangeTimes->{{3.6826658237576056`*^9, 3.6826658279897814`*^9}},ExpressionUUID->"0ba5d363-4895-495b-8fc0-\ 537f0d95a48a"], Cell[BoxData[ RowBox[{"Histogram", "[", " ", RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"Mean", "[", " ", RowBox[{"RandomVariate", "[", " ", RowBox[{ RowBox[{"ChiSquareDistribution", "[", "5", "]"}], ",", "10"}], "]"}], " ", "]"}], ",", RowBox[{"{", "1000", "}"}]}], "]"}], " ", "]"}]], "Input", CellChangeTimes->{{3.682665831298793*^9, 3.6826658630758076`*^9}},ExpressionUUID->"a8743d17-0353-4ed3-9797-\ 59916182caa7"], Cell[BoxData[ RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{"Histogram", "[", " ", RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"Mean", "[", " ", RowBox[{"RandomVariate", "[", " ", RowBox[{ RowBox[{"ChiSquareDistribution", "[", "n", "]"}], ",", "10"}], "]"}], " ", "]"}], ",", RowBox[{"{", "1000", "}"}]}], "]"}], " ", "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "30", ",", "1"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.682665871259787*^9, 3.6826658991118107`*^9}},ExpressionUUID->"22d9313a-82be-4bd0-856a-\ 4bd29106f414"], Cell[BoxData[ RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{"Histogram", "[", " ", RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"Mean", "[", " ", RowBox[{"RandomVariate", "[", " ", RowBox[{ RowBox[{"ChiSquareDistribution", "[", "n", "]"}], ",", "m"}], "]"}], " ", "]"}], ",", RowBox[{"{", "1000", "}"}]}], "]"}], " ", "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "30", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", "30", ",", "1"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.6826659214940987`*^9, 3.6826659389521627`*^9}, { 3.6826659957396984`*^9, 3.682666009103011*^9}},ExpressionUUID->"5a745cd1-f211-4613-9672-\ bff7885cc673"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Using Mathematica in place of the tables of t, ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["\[Chi]", "2"], ",", " "}], TraditionalForm]], ExpressionUUID->"a5762f13-a24d-411f-9c72-addf3faae53b"], "etc" }], "Subsection", CellChangeTimes->{{3.6999008317559075`*^9, 3.699900876985115*^9}},ExpressionUUID->"513370be-c575-45b9-98df-\ 2659e1319bcd"], Cell[BoxData[ RowBox[{"CDF", "[", RowBox[{ RowBox[{"StudentTDistribution", "[", "\[Nu]", "]"}], ",", "x"}], "]"}]], "Input", CellChangeTimes->{{3.6999008917093687`*^9, 3.6999009212211094`*^9}},ExpressionUUID->"f555289a-c902-4365-8a2b-\ d76e12769fc5"], Cell[BoxData[ RowBox[{ RowBox[{"CDF", "[", RowBox[{ RowBox[{"StudentTDistribution", "[", "5", "]"}], ",", "1"}], "]"}], "//", "N"}]], "Input", CellChangeTimes->{{3.699900940237665*^9, 3.6999009523889627`*^9}},ExpressionUUID->"8dc98a48-f516-42da-8c40-\ ec298ccd3a0e"], Cell[BoxData[ RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"CDF", "[", RowBox[{ RowBox[{"StudentTDistribution", "[", "n", "]"}], ",", "1"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "10"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.699900956247427*^9, 3.6999009775030107`*^9}},ExpressionUUID->"f2367e11-cbdf-46a5-898d-\ d0636967c54f"], Cell["\<\ Note CDF[StudentTDistribution[n],1] -CDF[StudentTDistribution[n],-1] ==2 \ CDF[StudentTDistribution[n],1] -1 ONLY because pdf(t) is symmetric around 0\ \>", "Text", CellChangeTimes->{{3.6999023293391323`*^9, 3.6999024025087223`*^9}},ExpressionUUID->"3dbc027b-5b65-4baa-8c0e-\ 8b8c58b5fb7f"], Cell[BoxData[ RowBox[{"TableForm", "[", " ", RowBox[{ RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"{", RowBox[{"n", ",", RowBox[{"N", "[", RowBox[{ RowBox[{"2", " ", RowBox[{"CDF", "[", RowBox[{ RowBox[{"StudentTDistribution", "[", "n", "]"}], ",", "1"}], "]"}]}], " ", "-", "1"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"n", ",", "10"}], "}"}]}], "]"}], " ", ",", RowBox[{"TableHeadings", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{"\[Nu]", ",", "\"\
\""}], "}"}]}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.6999009876812906`*^9, 3.6999010841639*^9}, { 3.699901133194194*^9, 3.6999012053667407`*^9}, {3.6999022538134394`*^9, 3.699902265935616*^9}},ExpressionUUID->"16bee65a-47f1-42eb-85f5-\ e4af9ae98e63"], Cell[BoxData[ RowBox[{"TableForm", "[", " ", RowBox[{ RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"{", RowBox[{"n", ",", RowBox[{"1", "-", RowBox[{"N", "[", RowBox[{"CDF", "[", RowBox[{ RowBox[{"ChiSquareDistribution", "[", "n", "]"}], ",", RowBox[{"2", "n"}]}], "]"}], " ", "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"n", ",", "10"}], "}"}]}], "]"}], " ", ",", RowBox[{"TableHeadings", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{ "\[Nu]", ",", "\"\
2\[Nu])\>\""}],
"}"}]}], "}"}]}]}], "]"}]], "Input",
CellChangeTimes->{{3.6999010741246777`*^9, 3.699901075292341*^9}, {
3.6999012173094425`*^9,
3.6999013274190416`*^9}},ExpressionUUID->"fdd89d8c-eaa2-495a-b81a-\
bb05f9e95d26"],
Cell["Just for exercising; now use InverseCDF[\[Nu],x]", "Text",
CellChangeTimes->{{3.889697842441761*^9,
3.889697875704953*^9}},ExpressionUUID->"eeb36c9c-3978-47eb-ad28-\
ccff6d89c7a4"],
Cell[BoxData[
RowBox[{"NSolve", "[", " ",
RowBox[{
RowBox[{
RowBox[{"1", "-",
RowBox[{"CDF", "[",
RowBox[{
RowBox[{"ChiSquareDistribution", "[", "7", "]"}], ",", "x"}], "]"}]}],
" ", "\[Equal]", "0.05"}], " ", ",", " ", "x"}], "]"}]], "Input",
CellChangeTimes->{{3.699901342632009*^9,
3.6999013750707307`*^9}},ExpressionUUID->"1deba3e3-cac0-4362-856b-\
f50eb8627e90"],
Cell[BoxData[
RowBox[{"FindRoot", "[", " ",
RowBox[{
RowBox[{
RowBox[{"1", "-",
RowBox[{"CDF", "[",
RowBox[{
RowBox[{"ChiSquareDistribution", "[", "7", "]"}], ",", "x"}], "]"}]}],
" ", "\[Equal]", "0.05"}], " ", ",", " ",
RowBox[{"{",
RowBox[{"x", ",", "14"}], "}"}]}], "]"}]], "Input",
CellChangeTimes->{{3.6999013913446674`*^9,
3.6999014335201883`*^9}},ExpressionUUID->"d3705258-14b6-4020-b4d4-\
b0bd5b85b1a2"],
Cell[BoxData[
RowBox[{
RowBox[{"Table", "[", " ",
RowBox[{
RowBox[{"{",
RowBox[{"n", ",",
RowBox[{"FindRoot", "[", " ",
RowBox[{
RowBox[{
RowBox[{"1", "-",
RowBox[{"CDF", "[",
RowBox[{
RowBox[{"ChiSquareDistribution", "[", "n", "]"}], ",", "x"}],
"]"}]}], " ", "\[Equal]", "0.05"}], " ", ",", " ",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"2", "n"}]}], "}"}]}], "]"}]}], "}"}], ",",
RowBox[{"{",
RowBox[{"n", ",", "10"}], "}"}]}], "]"}], " "}]], "Input",
CellChangeTimes->{{3.6999014507969313`*^9,
3.69990151105624*^9}},ExpressionUUID->"b79f611b-51fb-4c5b-8414-\
9d4719892491"],
Cell[BoxData[
RowBox[{"tab", "=",
RowBox[{"Table", "[", " ",
RowBox[{
RowBox[{"{",
RowBox[{"n", ",",
RowBox[{"x", "/.",
RowBox[{"FindRoot", "[", " ",
RowBox[{
RowBox[{
RowBox[{"1", "-",
RowBox[{"CDF", "[",
RowBox[{
RowBox[{"ChiSquareDistribution", "[", "n", "]"}], ",", "x"}],
"]"}]}], " ", "\[Equal]", "0.05"}], " ", ",", " ",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"2", "n"}]}], "}"}]}], "]"}]}]}], "}"}], ",",
RowBox[{"{",
RowBox[{"n", ",", "10"}], "}"}]}], "]"}], " "}]], "Input",
CellChangeTimes->{{3.6999015150525184`*^9,
3.6999015264436507`*^9}},ExpressionUUID->"4ecc940e-2619-4ca2-9fc8-\
5683e9333bda"],
Cell[BoxData[
RowBox[{"TableForm", "[",
RowBox[{"tab", ",",
RowBox[{"TableHeadings", "\[Rule]",
RowBox[{"{",
RowBox[{"None", ",",
RowBox[{"{",
RowBox[{
"\[Nu]", ",",
"\"\<\!\(\*SubscriptBox[\((\*SuperscriptBox[\(\[Chi]\), \(2\)])\), \
\(critico\)]\) | P(\!\(\*SuperscriptBox[\(\[Chi]\), \
\(2\)]\)>\!\(\*SubscriptBox[\((\*SuperscriptBox[\(\[Chi]\), \(2\)])\), \
\(critico\)]\))=5%\>\""}], "}"}]}], "}"}]}]}], "]"}]], "Input",
CellChangeTimes->{{3.699901530024841*^9,
3.6999016248112535`*^9}},ExpressionUUID->"47cf6f85-d084-4e57-b304-\
90ebcb0e7ddf"],
Cell["\<\
now, using InverseCDF; it may need some work to get the intended result\
\>", "Text",
CellChangeTimes->{{3.8896978996542706`*^9,
3.8896979481528196`*^9}},ExpressionUUID->"80d71fc5-e759-4729-a9f8-\
8f25fc2c735b"],
Cell[BoxData[
RowBox[{"InverseCDF", "[",
RowBox[{
RowBox[{"ChiSquareDistribution", "[", "7", "]"}], ",", "0.95"}],
"]"}]], "Input",
CellChangeTimes->{{3.8896980020024652`*^9, 3.889698020310994*^9}, {
3.889698052023201*^9,
3.889698052512785*^9}},ExpressionUUID->"334cd90e-fe29-45c7-b8c4-\
f29f219e4d74"],
Cell[BoxData[
RowBox[{"InverseCDF", "[",
RowBox[{
RowBox[{"StudentTDistribution", "[", "2", "]"}], ",",
RowBox[{"0.5", "-",
RowBox[{"0.683", "/", "2"}]}]}], "]"}]], "Input",ExpressionUUID->\
"594e8d23-679e-481d-b668-7617e34ed888"],
Cell[BoxData[
RowBox[{
RowBox[{"InverseCDF", "[",
RowBox[{
RowBox[{"StudentTDistribution", "[", "200", "]"}], ",",
RowBox[{"0.5", "+",
RowBox[{"0.683", "/", "2"}]}]}], "]"}], " ",
RowBox[{"(*", " ",
RowBox[{
RowBox[{"this", " ", "will", " ", "give", " ", "1"}], ",", "00"}], " ",
"*)"}]}]], "Input",
CellChangeTimes->{{3.889697963371252*^9,
3.8896979867710447`*^9}},ExpressionUUID->"696774dd-8262-4490-ad4a-\
6696ef7a3b83"]
}, Open ]]
}, Open ]],
Cell[CellGroupData[{
Cell["Exerc\[IAcute]cio 10", "Section",
CellChangeTimes->{{3.6999020181901484`*^9, 3.6999020224716144`*^9}, {
3.6999046050129976`*^9,
3.6999046055659704`*^9}},ExpressionUUID->"7a2b5a70-a66d-419a-8e64-\
050820a2c892"],
Cell[TextData[{
"Em uma medi\[CCedilla]\[ATilde]o com N dados, todos distribu\[IAcute]dos \
normalmente com m\[EAcute]dia ",
Cell[BoxData[
FormBox[
SubscriptBox["x", "0"], TraditionalForm]],ExpressionUUID->
"06b5cdb4-3d94-4e4c-a533-1fa4d5ad2bde"],
" e desvio-padr\[ATilde]o ",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]", "0"], TraditionalForm]],ExpressionUUID->
"9762f0af-5207-4bdb-b498-bca3805e8068"],
" , os n\[IAcute]veis de confian\[CCedilla]a associados aos intervalos \n",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"6da8ef58-c16f-441c-b643-742cbbaea615"],
" - ",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]",
RowBox[{"m", ",", "0"}]], TraditionalForm]],ExpressionUUID->
"4b4ce95e-b644-4ee8-8f2e-ccb7022e7061"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
RowBox[{" ",
SubscriptBox["x", "0"]}], TraditionalForm]],ExpressionUUID->
"ddeb56e8-f25f-4daf-9671-49b2159eae48"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"3ad11c54-5fe9-497e-9d86-df8d7302db7d"],
" + ",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]",
RowBox[{"m", ",", "0"}]], TraditionalForm]],ExpressionUUID->
"dae84c76-3d65-4a21-b491-6180f4a77980"],
" , ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"ac4f0f2b-ac2b-4201-a6d2-dc177c7ad71f"],
" - 2",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]",
RowBox[{"m", ".0"}]], TraditionalForm]],ExpressionUUID->
"c5a8283f-1711-4c53-b98b-35c2e32f8601"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
RowBox[{" ",
SubscriptBox["x", "0"]}], TraditionalForm]],ExpressionUUID->
"9db1fe44-354a-4b93-a8a2-429339f11bd7"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"e92deecc-376b-45d7-8acb-b4c1db29c4f9"],
" + ",
Cell[BoxData[
FormBox[
RowBox[{"2",
SubscriptBox["\[Sigma]",
RowBox[{"m", ".0"}]]}], TraditionalForm]],ExpressionUUID->
"0a051596-6e9c-4217-9cb9-06fd76c515a0"],
" e ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"8242f7ca-b0d8-410d-9071-ca5fdecc8af2"],
" - 3 ",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]",
RowBox[{"m", ",", "0"}]], TraditionalForm]],ExpressionUUID->
"e14f04f2-2b88-44b4-a161-b453c8628aaf"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
RowBox[{" ",
SubscriptBox["x", "0"]}], TraditionalForm]],ExpressionUUID->
"043022d5-ef49-4a8e-95d2-051660c543a2"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"e6d75104-05da-4a5d-bc7c-efd917b62a63"],
" + 3 ",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]",
RowBox[{"m", ",", "0"}]], TraditionalForm]],ExpressionUUID->
"4df16ff4-6860-44a1-81de-13e26d69c84e"],
" \ns\[ATilde]o 68,3%; 95,4% e 99,7%, respectivamente.\nSe o desvio-padr\
\[ATilde]o verdadeiro da m\[EAcute]dia \[EAcute] desconhecido e usamos sua \
estimativa convencional no lugar de ",
Cell[BoxData[
FormBox[
SubscriptBox["\[Sigma]",
RowBox[{"m", ",", "0"}]], TraditionalForm]],ExpressionUUID->
"147ef4ce-ec5e-4ad4-8172-dba89789385e"],
" nos intervalos acima, a fiim de manter esses n\[IAcute]veis de confian\
\[CCedilla]a usuais precisamos usar intervalos\n",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"6c882a94-298e-40c1-bab7-6c610d0f8f82"],
" - ",
Cell[BoxData[
FormBox[
RowBox[{
SubscriptBox["t", "I"], " ",
SubscriptBox["\[Sigma]", "m"]}], TraditionalForm]],ExpressionUUID->
"427cfa51-632b-462c-866b-45fc4b1e6a34"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
RowBox[{" ",
SubscriptBox["x", "0"]}], TraditionalForm]],ExpressionUUID->
"ba5263ac-4fde-4546-810d-7843e841932a"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"be004eb1-1d03-4dc7-93cc-448a30e9dbf5"],
" + ",
Cell[BoxData[
FormBox[
RowBox[{" ",
FormBox[
RowBox[{
SubscriptBox["t", "I"], " ",
SubscriptBox["\[Sigma]", "m"]}],
TraditionalForm]}], TraditionalForm]],ExpressionUUID->
"e6866642-95d8-4db3-a8b8-3ee6ec12b14b"],
", ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"c3d93bb6-5009-41c5-98f1-1f1ff84bd8c8"],
" - ",
Cell[BoxData[
FormBox[
RowBox[{
SubscriptBox["t", "II"], " ",
SubscriptBox["\[Sigma]", "m"]}], TraditionalForm]],ExpressionUUID->
"b069ee54-04e1-48ca-83af-09520d010534"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
RowBox[{" ",
SubscriptBox["x", "0"]}], TraditionalForm]],ExpressionUUID->
"e47bb97d-680c-4188-848f-c7ef2ed68093"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"4fddd2d4-0a81-46e4-9548-77380ed4a7ef"],
" + ",
Cell[BoxData[
FormBox[
RowBox[{" ",
FormBox[
RowBox[{
SubscriptBox["t", "II"], " ",
SubscriptBox["\[Sigma]", "m"]}],
TraditionalForm]}], TraditionalForm]],ExpressionUUID->
"2c783c28-4fe3-49d9-b8e9-add47df2c0dc"],
" e ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"cc057113-3231-41c1-927a-b32c033f49d1"],
" - ",
Cell[BoxData[
FormBox[
RowBox[{
SubscriptBox["t", "III"], " ",
SubscriptBox["\[Sigma]", "m"]}], TraditionalForm]],ExpressionUUID->
"0486c014-0469-4555-b7ec-5d7615fcba4f"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
RowBox[{" ",
SubscriptBox["x", "0"]}], TraditionalForm]],ExpressionUUID->
"38470bc7-e500-4a0a-88cf-41defe9e28ee"],
" \[LessEqual] ",
Cell[BoxData[
FormBox[
OverscriptBox["x", "_"], TraditionalForm]],ExpressionUUID->
"52a1b191-69c3-4c63-a819-b04c9bfffabf"],
" + ",
Cell[BoxData[
FormBox[
RowBox[{" ",
FormBox[
RowBox[{
SubscriptBox["t", "III"], " ",
SubscriptBox["\[Sigma]", "m"]}],
TraditionalForm]}], TraditionalForm]],ExpressionUUID->
"9990c2ac-8c50-4c40-94cc-55f7c2408fd7"],
"\ncom valores adequados de ",
Cell[BoxData[
FormBox[
RowBox[{
SubscriptBox["t", "I"], ",", " "}], TraditionalForm]],ExpressionUUID->
"36b14667-18c4-4f73-b7b6-9ac2b48d3471"],
Cell[BoxData[
FormBox[
SubscriptBox["t", "II"], TraditionalForm]],ExpressionUUID->
"3eed4972-cb26-45e2-91cb-68df51fb44a0"],
" e ",
Cell[BoxData[
FormBox[
SubscriptBox["t", "III"], TraditionalForm]],ExpressionUUID->
"a1cb86d8-b056-49b2-8489-148a031ce95b"],
", que devem ser obtidos a partir da distribui\[CCedilla]\[ATilde]o de t de \
Student.\nConstrua uma tabela de ",
Cell[BoxData[
FormBox[
RowBox[{
SubscriptBox["t", "I"], ",", " "}], TraditionalForm]],ExpressionUUID->
"8f437609-1858-441d-bb80-f0279be17f2b"],
Cell[BoxData[
FormBox[
SubscriptBox["t", "II"], TraditionalForm]],ExpressionUUID->
"e9fc938e-0095-4bee-8230-67703a80c749"],
" e ",
Cell[BoxData[
FormBox[
SubscriptBox["t", "III"], TraditionalForm]],ExpressionUUID->
"0d02cc16-99a8-4885-ae22-1f2480820aff"],
" para um n\[UAcute]mero de dados 2