(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.4' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 16829, 476] NotebookOptionsPosition[ 15703, 436] NotebookOutlinePosition[ 16052, 451] CellTagsIndexPosition[ 16009, 448] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Illustrating Errors Type I and Type II with a decision function\ \>", "Title", CellChangeTimes->{{3.6693734591181154`*^9, 3.669373495837107*^9}, { 3.66939247026562*^9, 3.6693924786355324`*^9}}], Cell[CellGroupData[{ Cell["\<\ Loss function - dependence with the relative probability of contamination by \ Iodine\ \>", "Section", CellChangeTimes->{{3.669373566483525*^9, 3.6693735690168805`*^9}, { 3.669566257165818*^9, 3.6695663328777804`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"loss", "[", RowBox[{"tExp_", ",", "pI_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"\[Alpha]", ",", "\[Beta]", ",", RowBox[{"tI", "=", "12.36"}], ",", RowBox[{"penaltyI", "=", "3"}], ",", RowBox[{"penaltyII", "=", "1"}], ",", RowBox[{"tX", "=", "13.02"}], ",", RowBox[{"\[Sigma]", "=", "0.22"}]}], "}"}], ",", RowBox[{ RowBox[{"\[Alpha]", "=", RowBox[{"1", "-", RowBox[{"CDF", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"tI", ",", "\[Sigma]"}], "]"}], ",", "tExp"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Beta]", "=", RowBox[{"CDF", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"tX", ",", "\[Sigma]"}], "]"}], ",", "tExp"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"pI", RowBox[{"(", RowBox[{ RowBox[{"\[Alpha]", " ", "penaltyI"}], " ", "+", RowBox[{ RowBox[{"(", RowBox[{"1", "-", "\[Alpha]"}], ")"}], "penaltyII"}]}], ")"}]}], "+", " ", RowBox[{ RowBox[{"(", RowBox[{"1", "-", "pI"}], ")"}], "penaltyII", " ", "\[Beta]"}]}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.669372634031127*^9, 3.6693728895217953`*^9}, { 3.669373526656205*^9, 3.669373528790095*^9}, {3.6695655269482164`*^9, 3.669565591916568*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"loss", "[", RowBox[{"tExp", ",", "0.5"}], "]"}], ",", RowBox[{"{", RowBox[{"tExp", ",", "12.3", ",", "13.1"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.6693729088996043`*^9, 3.669372932817412*^9}, { 3.669373534145754*^9, 3.66937353641089*^9}, {3.669390905476823*^9, 3.6693909461475663`*^9}, {3.669392042649149*^9, 3.6693920512965994`*^9}, { 3.6695656037488003`*^9, 3.669565604898942*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"tExp", ",", RowBox[{"loss", "[", RowBox[{"tExp", ",", "0.5"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"tExp", ",", "12.36", ",", "13.02", ",", "0.066"}], "}"}]}], "]"}], "//", "TableForm"}]], "Input", CellChangeTimes->{{3.6693931740435123`*^9, 3.6693932244547186`*^9}, { 3.669565617027115*^9, 3.669565617954978*^9}}], Cell[BoxData[ RowBox[{"minimum", "=", RowBox[{"FindMinimum", "[", RowBox[{ RowBox[{"loss", "[", RowBox[{"t", ",", "0.5"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "12.8"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.669373034351988*^9, 3.6693730499294643`*^9}, { 3.669373550258769*^9, 3.6693735521377816`*^9}, {3.6695656423312683`*^9, 3.669565643259681*^9}, {3.6697146509770303`*^9, 3.6697146527450356`*^9}}], Cell[BoxData[ RowBox[{"tCritical", "=", RowBox[{"Round", "[", " ", RowBox[{ RowBox[{"t", "/.", RowBox[{"minimum", "[", RowBox[{"[", "2", "]"}], "]"}]}], ",", "0.01"}], "]"}]}]], "Input", CellChangeTimes->{{3.6697146572769876`*^9, 3.669714670636687*^9}, { 3.6697147579093094`*^9, 3.669714764540349*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Investigating the dependence with other parameters than Iodine contamination\ \>", "Section", CellChangeTimes->{{3.669566235198843*^9, 3.6695662531261854`*^9}, { 3.669566343205993*^9, 3.6695663488617973`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"loss", "[", RowBox[{ "tExp_", ",", "pI_", ",", "penaltyI_", ",", "penaltyII_", ",", "\[Sigma]_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"\[Alpha]", ",", "\[Beta]", ",", RowBox[{"tI", "=", "12.36"}], ",", RowBox[{"tX", "=", "13.02"}]}], "}"}], ",", RowBox[{ RowBox[{"\[Alpha]", "=", RowBox[{"1", "-", RowBox[{"CDF", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"tI", ",", "\[Sigma]"}], "]"}], ",", "tExp"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Beta]", "=", RowBox[{"CDF", "[", RowBox[{ RowBox[{"NormalDistribution", "[", RowBox[{"tX", ",", "\[Sigma]"}], "]"}], ",", "tExp"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"pI", RowBox[{"(", RowBox[{ RowBox[{"\[Alpha]", " ", "penaltyI"}], " ", "+", RowBox[{ RowBox[{"(", RowBox[{"1", "-", "\[Alpha]"}], ")"}], "penaltyII"}]}], ")"}]}], "+", " ", RowBox[{ RowBox[{"(", RowBox[{"1", "-", "pI"}], ")"}], "penaltyII", " ", "\[Beta]"}]}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.669390323510332*^9, 3.669390369260321*^9}, { 3.6695656868106585`*^9, 3.6695657107800803`*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", " ", RowBox[{ RowBox[{"loss", "[", RowBox[{"tCritical", ",", "0.5", ",", "3", ",", "1", ",", "s"}], "]"}], ",", RowBox[{"{", RowBox[{"s", ",", "0.05", ",", "0.5"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\<\[Sigma] (h)\>\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"StringJoin", "[", " ", RowBox[{"\"\\"", ",", RowBox[{"ToString", "[", "tCritical", "]"}], ",", "\"\< h\>\""}], "]"}]}], " ", ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", RowBox[{"FontSize", "\[Rule]", "14"}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.6693903917577257`*^9, 3.6693904425228033`*^9}, { 3.6693920693924713`*^9, 3.6693921157603593`*^9}, {3.6695657191705427`*^9, 3.6695657411381097`*^9}, {3.6697146861369925`*^9, 3.6697147433698893`*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", " ", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"loss", "[", RowBox[{"tCritical", ",", "0.5", ",", "3", ",", "p", ",", "0.22"}], "]"}], ",", RowBox[{"loss", "[", RowBox[{"tCritical", ",", "0.5", ",", "p", ",", "1", ",", "0.22"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"p", ",", "0.5", ",", "5"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"StringJoin", "[", " ", RowBox[{"\"\\"", ",", RowBox[{"ToString", "[", "tCritical", "]"}], ",", "\"\< h, \[Sigma]=0.22 h\>\""}], "]"}]}], ",", RowBox[{"PlotLabels", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", RowBox[{"FontSize", "\[Rule]", "14"}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.669390468633256*^9, 3.6693905259834995`*^9}, { 3.669392139380015*^9, 3.6693922339843235`*^9}, {3.6695657545060015`*^9, 3.6695657755474463`*^9}, {3.6697147816013627`*^9, 3.669714822814722*^9}, { 3.6697150308015757`*^9, 3.669715035937151*^9}, {3.6697161514497633`*^9, 3.6697162844784875`*^9}}], Cell[BoxData[ RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"Plot", "[", " ", RowBox[{ RowBox[{"loss", "[", RowBox[{"tc", ",", "0.5", ",", "penaltyI", ",", "1", ",", "s"}], "]"}], ",", RowBox[{"{", RowBox[{"tc", ",", "12.4", ",", "13.5"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"s", ",", "0.22"}], "}"}], ",", "0.05", ",", "0.5"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"penaltyI", ",", "3"}], "}"}], ",", "0.5", ",", "10"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.669390558514943*^9, 3.669390573449094*^9}, { 3.6693906040753574`*^9, 3.6693906590824423`*^9}, {3.669390734582376*^9, 3.669390767386343*^9}, {3.6693908674645367`*^9, 3.669390868032677*^9}, 3.66939098435454*^9, {3.66939225149197*^9, 3.6693922595461197`*^9}, { 3.6695658229298944`*^9, 3.669565824977668*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Simulation using most of the parameters fixed", "Section", CellChangeTimes->{{3.669373581613244*^9, 3.6693735832143936`*^9}, 3.669393836908943*^9, {3.6695663602061176`*^9, 3.669566378141562*^9}, { 3.669715875675984*^9, 3.6697159163450594`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"lossSE", "[", RowBox[{"tCritical_", ",", "probI_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"halfLife", ",", "tExp", ",", RowBox[{"tI", "=", "12.36"}], ",", RowBox[{"penaltyI", "=", "3"}], ",", RowBox[{"penaltyII", "=", "1"}], ",", RowBox[{"tX", "=", "13.02"}], ",", RowBox[{"\[Sigma]", "=", "0.22"}]}], "}"}], ",", RowBox[{ RowBox[{"halfLife", "=", RowBox[{"RandomChoice", "[", RowBox[{ RowBox[{"{", RowBox[{"probI", ",", RowBox[{"1", "-", "probI"}]}], "}"}], "->", RowBox[{"{", RowBox[{"tI", ",", "tX"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"tExp", "=", RowBox[{"RandomVariate", "[", RowBox[{"NormalDistribution", "[", RowBox[{"halfLife", ",", "\[Sigma]"}], "]"}], " ", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"reject", " ", "=", " ", RowBox[{"tExp", ">", "tCritical"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{"reject", ",", RowBox[{"If", "[", " ", RowBox[{ RowBox[{"halfLife", "\[Equal]", "tI"}], ",", "penaltyI", ",", "0"}], "]"}], ",", "1"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.6693736044477787`*^9, 3.669373923414576*^9}, { 3.669373967032472*^9, 3.6693739686180944`*^9}, {3.66938761758152*^9, 3.6693877538561697`*^9}, {3.6693878006363735`*^9, 3.669387813863531*^9}, { 3.669565928265419*^9, 3.669565930745037*^9}, {3.6695660043368845`*^9, 3.669566012344515*^9}, {3.6697154008565745`*^9, 3.669715407242994*^9}, { 3.6697154624128294`*^9, 3.6697154996622047`*^9}, 3.669715590744047*^9}], Cell[BoxData[ RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"lossSE", "[", RowBox[{"tCritical", ",", "0.5"}], "]"}], ",", RowBox[{"{", "100", "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.669388034731536*^9, 3.669388035069352*^9}, { 3.669565945561777*^9, 3.66956594580913*^9}, 3.669715697219782*^9}], Cell[BoxData[ RowBox[{"u", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"p", ",", RowBox[{"0.0001", RowBox[{"Total", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"lossSE", "[", RowBox[{"tCritical", ",", "p"}], "]"}], ",", RowBox[{"{", "10000", "}"}]}], "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"p", ",", "0.01", ",", "0.99", ",", "0.02"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.669388118936145*^9, 3.6693882925381308`*^9}, { 3.669388349980294*^9, 3.6693883566515083`*^9}, {3.669392006469475*^9, 3.6693920072019196`*^9}, {3.6695660386806483`*^9, 3.6695660394078636`*^9}, 3.66971570168954*^9}], Cell[BoxData[" "], "Input", CellChangeTimes->{3.6693893772479005`*^9}], Cell[BoxData[ RowBox[{"simul", "=", RowBox[{"ListPlot", "[", RowBox[{"u", ",", RowBox[{"AxesLabel", "->", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", RowBox[{"FontSize", "\[Rule]", "16"}], "}"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.6693882605550847`*^9, 3.66938826371195*^9}, { 3.6693935008601527`*^9, 3.6693935515177827`*^9}, {3.6693937377903886`*^9, 3.669393792874343*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"simul", ",", RowBox[{"Plot", "[", " ", RowBox[{ RowBox[{"loss", "[", RowBox[{"tCritical", ",", "pI"}], "]"}], ",", RowBox[{"{", RowBox[{"pI", ",", "0", ",", "1"}], "}"}]}], "]"}]}], " ", "]"}]], "Input", CellChangeTimes->{{3.66938949079449*^9, 3.6693895636708555`*^9}, 3.669393755886363*^9, {3.6693937993636255`*^9, 3.6693938003953123`*^9}, { 3.669566091680069*^9, 3.669566091991697*^9}, 3.669715713501017*^9}], Cell[BoxData[ RowBox[{"Show", "[", " ", RowBox[{ RowBox[{"Table", "[", " ", RowBox[{ RowBox[{"Plot", "[", " ", RowBox[{ RowBox[{"loss", "[", RowBox[{"tExp", ",", "pI"}], "]"}], ",", RowBox[{"{", RowBox[{"tExp", ",", "12.3", ",", "13.1"}], "}"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"PlotLabels", "\[Rule]", RowBox[{"ToString", "[", "pI", " ", "]"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{ RowBox[{"ColorData", "[", "\"\\"", "]"}], "[", RowBox[{"[", RowBox[{"Round", "[", RowBox[{"10", "pI"}], "]"}], " ", "]"}], "]"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"pI", ",", "0.1", ",", "0.9", ",", "0.2"}], "}"}]}], "]"}], " ", ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", RowBox[{"FontSize", "\[Rule]", "14"}], "}"}]}], ",", RowBox[{"Epilog", "\[Rule]", RowBox[{"{", RowBox[{"Green", ",", "Thick", ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"12.3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"13.1", ",", "1"}], "}"}]}], "}"}], "]"}]}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.6693913281424804`*^9, 3.669391512591733*^9}, { 3.6693916788623405`*^9, 3.669391709356093*^9}, {3.669391797114537*^9, 3.66939186843253*^9}, {3.669391930171445*^9, 3.6693919652970657`*^9}, { 3.6693923391134996`*^9, 3.6693923539285946`*^9}, {3.66956615271555*^9, 3.6695661585437346`*^9}, {3.6697157309208975`*^9, 3.669715731220381*^9}, { 3.6697166151389465`*^9, 3.669716704269556*^9}}] }, Open ]] }, Open ]] }, WindowSize->{1032, 833}, WindowMargins->{{Automatic, 413}, {Automatic, 52}}, 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, 206, 4, 166, "Title"], Cell[CellGroupData[{ Cell[811, 30, 231, 5, 70, "Section"], Cell[1045, 37, 1519, 42, 107, "Input"], Cell[2567, 81, 614, 14, 30, "Input"], Cell[3184, 97, 445, 12, 30, "Input"], Cell[3632, 111, 452, 10, 30, "Input"], Cell[4087, 123, 330, 8, 30, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[4454, 136, 222, 4, 70, "Section"], Cell[4679, 142, 1398, 40, 88, "Input"], Cell[6080, 184, 937, 21, 50, "Input"], Cell[7020, 207, 1364, 32, 69, "Input"], Cell[8387, 241, 1072, 28, 50, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[9496, 274, 258, 3, 70, "Section"], Cell[9757, 279, 1780, 41, 126, "Input"], Cell[11540, 322, 318, 7, 30, "Input"], Cell[11861, 331, 735, 19, 30, "Input"], Cell[12599, 352, 71, 1, 30, "Input"], Cell[12673, 355, 520, 12, 30, "Input"], Cell[13196, 369, 503, 12, 30, "Input"], Cell[13702, 383, 1973, 49, 88, "Input"] }, Open ]] }, Open ]] } ] *)