(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 14643, 350] NotebookOptionsPosition[ 13925, 330] NotebookOutlinePosition[ 14451, 348] CellTagsIndexPosition[ 14408, 345] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"moy", "=", "5"}], ";", "\[IndentingNewLine]", RowBox[{"dist", "=", RowBox[{"NormalDistribution", "[", RowBox[{"moy", ",", "2"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"taille", "=", "10"}], ";", "\[IndentingNewLine]", RowBox[{"z", "=", RowBox[{"Quantile", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"0", ",", "1"}], "]"}], ",", RowBox[{"1", "-", RowBox[{"alpha", "/", "2"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"sample", "[", "i", "]"}], "=", RowBox[{"RandomReal", "[", RowBox[{"dist", ",", "taille"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"occurrence", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"IntervalMemberQ", "[", RowBox[{ RowBox[{"Interval", "[", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"Mean", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "-", RowBox[{"z", "*", RowBox[{ RowBox[{"StandardDeviation", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "/", RowBox[{"Sqrt", "[", "taille", "]"}]}]}]}], ",", RowBox[{ RowBox[{"Mean", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "+", RowBox[{"z", "*", RowBox[{ RowBox[{"StandardDeviation", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "/", RowBox[{"Sqrt", "[", "taille", "]"}]}]}]}]}], "}"}], "]"}], ",", "moy"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Nb", "=", RowBox[{"Count", "[", RowBox[{"occurrence", ",", "True"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Column", "[", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Style", "[", RowBox[{ RowBox[{"\"\\"", "<>", RowBox[{"ToString", "@", "Nb"}]}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "18"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Style", "[", RowBox[{ RowBox[{"\"\<% d'occurrences : \>\"", "<>", RowBox[{"ToString", "[", RowBox[{"Round", "[", RowBox[{ RowBox[{"Nb", "/", "n"}], "*", "100"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "16"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Style", "[", RowBox[{ RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", RowBox[{ RowBox[{"(", RowBox[{"1", "-", "alpha"}], ")"}], "*", "100"}], "]"}]}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "16"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Show", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics", "@", RowBox[{"{", RowBox[{"White", ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"8", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"8", ",", RowBox[{"n", "+", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", RowBox[{"n", "+", "1"}]}], "}"}]}], "}"}], "]"}]}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"Graphics", "@", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "0.015", "]"}], ",", RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"Mean", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], ",", "i"}], "}"}], "]"}]}], "}"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics", "[", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"Mean", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "-", RowBox[{"z", "*", RowBox[{ RowBox[{"StandardDeviation", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "/", RowBox[{"Sqrt", "[", "taille", "]"}]}]}]}], ",", "i"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"Mean", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "+", RowBox[{"z", "*", RowBox[{ RowBox[{"StandardDeviation", "[", RowBox[{"sample", "[", "i", "]"}], "]"}], "/", RowBox[{"Sqrt", "[", "taille", "]"}]}]}]}], ",", "i"}], "}"}]}], "}"}], "]"}], "]"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"Frame", "\[Rule]", "True"}], ",", RowBox[{"ImageSize", "\[Rule]", RowBox[{"{", RowBox[{"900", ",", "600"}], "}"}]}], ",", RowBox[{"Epilog", "\[Rule]", RowBox[{"{", RowBox[{"Red", ",", "Thick", ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"moy", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"moy", ",", RowBox[{"n", "+", "1"}]}], "}"}]}], "}"}], "]"}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "}"}], "]"}]}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"n", ",", "10", ",", "\"\\""}], "}"}], ",", "1", ",", "100", ",", "1"}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "alpha", ",", "0.32", ",", "\"\<1-\[Alpha] intervalle de confiance, \[Alpha] =\>\""}], "}"}], ",", "0", ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"ContinuousAction", "\[Rule]", "None"}]}], "]"}]], "Input", CellChangeTimes->{{3.465039781375*^9, 3.465039883703125*^9}, { 3.46504005465625*^9, 3.465040172984375*^9}, {3.4650402056875*^9, 3.465040252703125*^9}, {3.465040638390625*^9, 3.46504075828125*^9}, 3.465040891578125*^9, {3.465041267578125*^9, 3.465041290890625*^9}, { 3.465041495109375*^9, 3.465041576953125*^9}, {3.465041653328125*^9, 3.46504180365625*^9}, {3.46504192625*^9, 3.46504202071875*^9}, { 3.465042257453125*^9, 3.46504232978125*^9}, {3.46504256784375*^9, 3.465042617078125*^9}, {3.46504278246875*^9, 3.465042785734375*^9}, { 3.46504292153125*^9, 3.46504303675*^9}, {3.465043073625*^9, 3.465043082671875*^9}, {3.46504312753125*^9, 3.465043140734375*^9}, { 3.465043259640625*^9, 3.465043456046875*^9}, {3.465044139140625*^9, 3.46504415859375*^9}, {3.465044229171875*^9, 3.465044248703125*^9}, { 3.46504429603125*^9, 3.465044319546875*^9}, {3.4650443570625*^9, 3.46504436521875*^9}, {3.46504443053125*^9, 3.465044446234375*^9}, { 3.465044488609375*^9, 3.465044675*^9}, {3.46504474675*^9, 3.465044749359375*^9}, {3.4650447961875*^9, 3.465044832890625*^9}, { 3.4650449395625*^9, 3.465044969171875*^9}, {3.592276955836381*^9, 3.592276956132781*^9}, 3.81182253077236*^9}, CellLabel->"In[25]:=",ExpressionUUID->"c078e4c7-0a3c-45d2-9524-c956d63cade7"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`alpha$$ = 0.5, $CellContext`n$$ = 10, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`n$$], 10, "nombre d'\[EAcute]chantillons"}, 1, 100, 1}, {{ Hold[$CellContext`alpha$$], 0.32, "1-\[Alpha] intervalle de confiance, \[Alpha] ="}, 0, 1}}, Typeset`size$$ = {900., {326.8, 332.8}}, Typeset`update$$ = 3.8118299691196316`17.33370850937388*^9, Typeset`initDone$$, Typeset`skipInitDone$$ = True}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`alpha$$ = 0.32, $CellContext`n$$ = 10}, "ControllerVariables" :> {}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> ($CellContext`moy = 5; $CellContext`dist = NormalDistribution[$CellContext`moy, 2]; $CellContext`taille = 10; $CellContext`z = Quantile[ NormalDistribution[0, 1], 1 - $CellContext`alpha$$/2]; Do[$CellContext`sample[$CellContext`i] = RandomReal[$CellContext`dist, $CellContext`taille], {$CellContext`i, \ $CellContext`n$$}]; $CellContext`occurrence = Table[ IntervalMemberQ[ Interval[{Mean[ $CellContext`sample[$CellContext`i]] - $CellContext`z ( StandardDeviation[ $CellContext`sample[$CellContext`i]]/ Sqrt[$CellContext`taille]), Mean[ $CellContext`sample[$CellContext`i]] + $CellContext`z ( StandardDeviation[ $CellContext`sample[$CellContext`i]]/ Sqrt[$CellContext`taille])}], $CellContext`moy], \ {$CellContext`i, $CellContext`n$$}]; $CellContext`Nb = Count[$CellContext`occurrence, True]; Column[{ Style[ StringJoin["nombre d'occurrences : ", ToString[$CellContext`Nb]], {"Times", 18}], Style[ StringJoin["% d'occurrences : ", ToString[ Round[($CellContext`Nb/$CellContext`n$$) 100]]], {"Times", 16}], Style[ StringJoin["Intervalle de confiance : ", ToString[(1 - $CellContext`alpha$$) 100]], {"Times", 16}], Show[ Graphics[{White, Line[{{2, 0}, {8, 0}, {8, $CellContext`n$$ + 1}, { 2, $CellContext`n$$ + 1}}]}], Table[ Graphics[{ PointSize[0.015], Point[{ Mean[ $CellContext`sample[$CellContext`i]], $CellContext`i}]}], \ {$CellContext`i, $CellContext`n$$}], Table[ Graphics[ Line[{{Mean[ $CellContext`sample[$CellContext`i]] - $CellContext`z ( StandardDeviation[ $CellContext`sample[$CellContext`i]]/ Sqrt[$CellContext`taille]), $CellContext`i}, {Mean[ $CellContext`sample[$CellContext`i]] + $CellContext`z ( StandardDeviation[ $CellContext`sample[$CellContext`i]]/ Sqrt[$CellContext`taille]), $CellContext`i}}]], \ {$CellContext`i, $CellContext`n$$}], Frame -> True, ImageSize -> {900, 600}, Epilog -> {Red, Thick, Line[{{$CellContext`moy, 0}, {$CellContext`moy, $CellContext`n$$ + 1}}]}]}]), "Specifications" :> {{{$CellContext`n$$, 10, "nombre d'\[EAcute]chantillons"}, 1, 100, 1}, {{$CellContext`alpha$$, 0.32, "1-\[Alpha] intervalle de confiance, \[Alpha] ="}, 0, 1}}, "Options" :> {ContinuousAction -> None}, "DefaultOptions" :> {}], ImageSizeCache->{946., {401., 407.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{ 3.5922772619245186`*^9, 3.7500779349900103`*^9, 3.750077996341653*^9, { 3.7815371959797134`*^9, 3.781537214444673*^9}, 3.811822502592551*^9, { 3.8118225411525803`*^9, 3.81182255866453*^9}}, CellLabel->"Out[25]=",ExpressionUUID->"fcc68d97-b5c1-4c22-9905-d54f04c48471"] }, Open ]], Cell[BoxData[""], "Input", CellChangeTimes->{{3.46504286803125*^9, 3.465042918390625*^9}},ExpressionUUID->"59a05aa5-d0d1-45f9-b18b-\ 3580f6850060"] }, WindowSize->{1635.4285714285713`, 853.2857142857142}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrivateNotebookOptions->{"VersionedStylesheet"->{"Default.nb"[8.] -> False}}, ShowSelection->True, FrontEndVersion->"12.1 for Microsoft Windows (64-bit) (March 14, 2020)", StyleDefinitions->"Default.nb", ExpressionUUID->"34078e06-26b5-442c-9562-2deceb8a76a2" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 8418, 198, 492, "Input",ExpressionUUID->"c078e4c7-0a3c-45d2-9524-c956d63cade7"], Cell[8988, 222, 4767, 100, 827, "Output",ExpressionUUID->"fcc68d97-b5c1-4c22-9905-d54f04c48471"] }, Open ]], Cell[13770, 325, 151, 3, 28, "Input",ExpressionUUID->"59a05aa5-d0d1-45f9-b18b-3580f6850060"] } ] *)