(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 27821, 682] NotebookOptionsPosition[ 26506, 633] NotebookOutlinePosition[ 26937, 650] CellTagsIndexPosition[ 26894, 647] WindowFrame->Normal ContainsDynamic->True *) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["MLEs and MAPs", "Title", CellChangeTimes->{{3.3984625771490726`*^9, 3.398462606901127*^9}, { 3.398466900639695*^9, 3.3984669028210278`*^9}}], Cell["Joseph E. Gonzalez", "Text", CellChangeTimes->{{3.398462740046832*^9, 3.398462743872199*^9}}], Cell[CellGroupData[{ Cell["Is it Learning...", "Subtitle", CellChangeTimes->{{3.398462714154646*^9, 3.398462715382607*^9}, { 3.3984627546071787`*^9, 3.398462773964181*^9}, {3.398463038359494*^9, 3.398463039265473*^9}}], Cell["\<\ In class we considered the problem of flipping a thumbtack. Let's put some \ of the magic back into learning by playing a simple game. I will place a \ coin in either my left or right hand. If you guess the correct hand you get \ the coin. \ \>", "Text", CellChangeTimes->{{3.3984602057255487`*^9, 3.398460376939501*^9}, 3.398461270650323*^9, {3.398463067187011*^9, 3.3984631050420303`*^9}}], Cell["\<\ Suppose you were designing a robot to play this game. You would want it to \ learn which hand I favor. If I charge you to play, you may also want to \ learn how much I favor one hand over the other. If we assume that my current \ choice of hand is independent of previous hand choices, you would likely want \ to solve the thumbtack problem discussed in class. \ \>", "Text", CellChangeTimes->{{3.398461281665975*^9, 3.39846132794969*^9}, { 3.398461399194721*^9, 3.39846144301772*^9}, {3.39846147403703*^9, 3.398461769597225*^9}, {3.39846181218423*^9, 3.3984618754333353`*^9}, { 3.398462797682025*^9, 3.3984630237477016`*^9}, {3.3984631251605797`*^9, 3.398463300865614*^9}, {3.39846756119656*^9, 3.398467586776408*^9}}], Cell[TextData[{ "From time to time I will try to compose a ", StyleBox["Mathematica", FontSlant->"Italic"], " demonstration notebook for you to play with the graphs and concepts \ presented in class." }], "Text", CellChangeTimes->{{3.3984633582649517`*^9, 3.398463387339952*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Likelihood", "Subtitle", CellChangeTimes->{{3.398463305773367*^9, 3.398463305938181*^9}, { 3.3984633998293858`*^9, 3.3984634068250513`*^9}}], Cell[TextData[{ "The following demonstration shows the plot of the data likelihood function \ with respect to the value of the parameter \[Theta] for different values of \ the data ", Cell[BoxData[ FormBox[ RowBox[{"D", "=", RowBox[{"{", RowBox[{ SubscriptBox["\[Alpha]", "H"], ",", SubscriptBox["\[Alpha]", "T"]}], "}"}]}], TraditionalForm]]] }], "Text", CellChangeTimes->{{3.3984634201272717`*^9, 3.398463421627632*^9}, { 3.398463470157967*^9, 3.398463553951007*^9}, {3.398463605347084*^9, 3.398463613342394*^9}, {3.39846764888245*^9, 3.398467665641746*^9}, { 3.398467696044363*^9, 3.398467696824958*^9}, {3.398467742200921*^9, 3.398467757151567*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"n", "=", "20"}], ";"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{ SuperscriptBox["\[Theta]", "h"], " ", SuperscriptBox[ RowBox[{"(", RowBox[{"1", "-", "\[Theta]"}], ")"}], "t"]}], ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\<\[Theta]\>\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"\"\<(\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)=\>\"", "<>", RowBox[{"ToString", "[", "h", "]"}], "<>", "\"\<, \!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)=\>\"", " ", "<>", " ", RowBox[{"ToString", "[", "t", "]"}], "<>", "\"\<)\>\""}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "h", ",", "3", ",", "\"\<\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)\>\""}], "}"}], ",", "0", ",", "n", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "t", ",", "3", ",", "\"\<\!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)\>\""}], "}"}], ",", "0", ",", "n", ",", "1"}], "}"}]}], "]"}]}], "Input", CellChangeTimes->{{3.398463567260326*^9, 3.398463599784747*^9}, { 3.39846363158537*^9, 3.3984636732936707`*^9}, {3.398463730374741*^9, 3.398463800570305*^9}, {3.398463836719531*^9, 3.398463845532794*^9}, { 3.3984639086067743`*^9, 3.398463931040599*^9}, {3.398463992143897*^9, 3.398464089849262*^9}, {3.398464146544834*^9, 3.398464226213574*^9}, { 3.3984668572516527`*^9, 3.398466875167938*^9}}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`h$$ = 0, $CellContext`t$$ = 0, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`h$$], 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)"}, 0, 20, 1}, {{ Hold[$CellContext`t$$], 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)"}, 0, 20, 1}}, Typeset`size$$ = {450., {154., 161.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`h$37653$$ = 0, $CellContext`t$37654$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`h$$ = 3, $CellContext`t$$ = 3}, "ControllerVariables" :> { Hold[$CellContext`h$$, $CellContext`h$37653$$, 0], Hold[$CellContext`t$$, $CellContext`t$37654$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Plot[$CellContext`\[Theta]^$CellContext`h$$ ( 1 - $CellContext`\[Theta])^$CellContext`t$$, {$CellContext`\[Theta], 0, 1}, AxesLabel -> {"\[Theta]", "P(D|\[Theta])"}, PlotLabel -> StringJoin["(\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)=", ToString[$CellContext`h$$], ", \!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)=", ToString[$CellContext`t$$], ")"]], "Specifications" :> {{{$CellContext`h$$, 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)"}, 0, 20, 1}, {{$CellContext`t$$, 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)"}, 0, 20, 1}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{494.5, {220.5, 227.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{ 3.398464150028273*^9, {3.398464220091257*^9, 3.398464226746992*^9}, 3.398466876667012*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Beta Distribution", "Subtitle", CellChangeTimes->{{3.3984642625428762`*^9, 3.398464264864565*^9}}], Cell[TextData[{ "In class we also introduced the Beta distribution which is the conjugate \ prior of the Bernoulli distribution. Alternatively, if we treat the \ parameter \[Theta] as a random variable, then we typically assume that \ \[Theta] is drawn from a Beta distribution. The Beta distribution is itself \ parameterized by two values ", Cell[BoxData[ FormBox[ SubscriptBox["\[Beta]", "H"], TraditionalForm]]], " and ", Cell[BoxData[ FormBox[ SubscriptBox["\[Beta]", "T"], TraditionalForm]]], "." }], "Text", CellChangeTimes->{{3.398464267978813*^9, 3.3984644599587812`*^9}, { 3.398467300600881*^9, 3.3984673034686832`*^9}, {3.398467335835832*^9, 3.398467350328505*^9}, 3.398467771120989*^9, {3.3984679686556377`*^9, 3.398467977728384*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"PDF", "[", RowBox[{ RowBox[{"BetaDistribution", "[", RowBox[{"\[Alpha]", ",", "\[Beta]"}], "]"}], ",", "\[Theta]"}], "]"}], ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\<\[Theta]\>\"", ",", "\"\\""}], "}"}]}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "Automatic"}], "}"}]}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"PlotLabel", " ", "\[Rule]", " ", RowBox[{"\"\<(\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)=\>\"", "<>", RowBox[{"ToString", "[", "\[Alpha]", "]"}], "<>", "\"\<, \!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)=\>\"", "<>", RowBox[{"ToString", "[", "\[Beta]", "]"}], "<>", "\"\<)\>\""}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "\[Alpha]", ",", "1", ",", "\"\<\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)\>\""}], "}"}], ",", "0", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "\[Beta]", ",", "1", ",", "\"\<\!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)\>\""}], "}"}], ",", "0", ",", "4"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.398464483565795*^9, 3.3984645643451014`*^9}, { 3.398464602395162*^9, 3.398464616798511*^9}, {3.398466448752433*^9, 3.398466457588498*^9}, {3.398467882901579*^9, 3.398467888044367*^9}, { 3.398468014493657*^9, 3.398468019147232*^9}, {3.398516142057756*^9, 3.398516157875298*^9}, {3.3985170906042347`*^9, 3.398517138332477*^9}}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`\[Alpha]$$ = 0.195, $CellContext`\[Beta]$$ = 0.195, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`\[Alpha]$$], 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)"}, 0, 4}, {{ Hold[$CellContext`\[Beta]$$], 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)"}, 0, 4}}, Typeset`size$$ = { 450., {154., 161.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`\[Alpha]$557$$ = 0, $CellContext`\[Beta]$558$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`\[Alpha]$$ = 1, $CellContext`\[Beta]$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`\[Alpha]$$, $CellContext`\[Alpha]$557$$, 0], Hold[$CellContext`\[Beta]$$, $CellContext`\[Beta]$558$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Plot[ PDF[ BetaDistribution[$CellContext`\[Alpha]$$, $CellContext`\[Beta]$$], \ $CellContext`\[Theta]], {$CellContext`\[Theta], 0, 1}, AxesLabel -> {"\[Theta]", "p(\[Theta])"}, PlotRange -> {{0, 1}, {0, Automatic}}, PlotLabel -> StringJoin["(\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)=", ToString[$CellContext`\[Alpha]$$], ", \!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)=", ToString[$CellContext`\[Beta]$$], ")"]], "Specifications" :> {{{$CellContext`\[Alpha]$$, 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)"}, 0, 4}, {{$CellContext`\[Beta]$$, 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)"}, 0, 4}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{494.5, {220.5, 227.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{{3.39846454028283*^9, 3.3984645649537354`*^9}, 3.398464617460828*^9, 3.398466460304537*^9, 3.3984678928241*^9, 3.3984680213501062`*^9, 3.398517142270302*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Being Bayesian", "Subtitle", CellChangeTimes->{{3.3984648125186863`*^9, 3.398464815841021*^9}}], Cell[TextData[{ "If we use a ", Cell[BoxData[ FormBox[ RowBox[{"Beta", "(", RowBox[{ SubscriptBox["\[Beta]", "H"], ",", SubscriptBox["\[Beta]", "T"]}], ")"}], TraditionalForm]]], " prior on ", Cell[BoxData[ FormBox["\[Theta]", TraditionalForm]]], " then we obtain the new likelihood. The red line is proportional to the \ likelihood ", Cell[BoxData[ FormBox[ RowBox[{"P", "(", RowBox[{"D", "|", "\[Theta]"}], ")"}], TraditionalForm]]], " used to compute the MLE and the blue line is proportional to the bayesian \ posterior ", Cell[BoxData[ FormBox[ RowBox[{"P", "(", RowBox[{"\[Theta]", "|", "D"}], ")"}], TraditionalForm]]], " used to compute the MAP." }], "Text", CellChangeTimes->{{3.398464881345537*^9, 3.398464922270751*^9}, { 3.398464957007257*^9, 3.398464962332693*^9}, {3.3984670788535957`*^9, 3.398467200270493*^9}, {3.3984680771368647`*^9, 3.398468078510509*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"n", "=", "20"}], ";"}], "\[IndentingNewLine]", RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"GraphicsGrid", "[", RowBox[{"{", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Plot", "[", RowBox[{ RowBox[{"PDF", "[", RowBox[{ RowBox[{"BetaDistribution", "[", RowBox[{"u", ",", "v"}], "]"}], ",", "\[Theta]"}], "]"}], ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\<\[Theta]\>\"", ",", "\"\\""}], "}"}]}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "Automatic"}], "}"}]}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"PlotLabel", " ", "\[Rule]", " ", RowBox[{ "\"\\"", "<>", RowBox[{"ToString", "[", "u", "]"}], "<>", "\"\<, \!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)=\>\"", "<>", RowBox[{"ToString", "[", "v", "]"}], "<>", "\"\<)\>\""}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ FractionBox["1", RowBox[{ SuperscriptBox[ RowBox[{"(", FractionBox["h", RowBox[{"h", "+", "t"}]], ")"}], "h"], " ", SuperscriptBox[ RowBox[{"(", RowBox[{"1", "-", FractionBox["h", RowBox[{"h", "+", "t"}]]}], ")"}], "t"]}]], SuperscriptBox["\[Theta]", "h"], " ", SuperscriptBox[ RowBox[{"(", RowBox[{"1", "-", "\[Theta]"}], ")"}], "t"]}], ",", "\[IndentingNewLine]", FractionBox[ RowBox[{"PDF", "[", RowBox[{ RowBox[{"BetaDistribution", "[", RowBox[{ RowBox[{"u", " ", "+", " ", "h"}], ",", RowBox[{"v", " ", "+", " ", "t"}]}], "]"}], ",", "\[Theta]"}], "]"}], RowBox[{"PDF", "[", RowBox[{ RowBox[{"BetaDistribution", "[", RowBox[{ RowBox[{"u", " ", "+", " ", "h"}], ",", RowBox[{"v", " ", "+", " ", "t"}]}], "]"}], ",", FractionBox[ RowBox[{"h", "+", "u", "-", "1"}], RowBox[{"h", "+", "u", "+", "t", "+", "v", "-", "2"}]]}], "]"}]]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<\[Theta]\>\"", ",", "\"\<\[Proportional]P(\[Theta]|D),\[Proportional]P(D|\[Theta])\>\"\ "}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"Red", ",", RowBox[{"Thickness", "[", ".01", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"Blue", ",", RowBox[{"Thickness", "[", ".01", "]"}]}], "}"}]}], "}"}]}], ",", " ", RowBox[{"PlotLabel", "\[Rule]", RowBox[{ "\"\<(\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)=\>\"", "<>", RowBox[{"ToString", "[", "h", "]"}], "<>", "\"\<, \!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)=\>\"", " ", "<>", " ", RowBox[{"ToString", "[", "t", "]"}], "<>", "\"\<)\>\""}]}], ",", "\[IndentingNewLine]", RowBox[{"PlotRange", "\[Rule]", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "}"}]}]}], "]"}]}], "}"}], "\[IndentingNewLine]", "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "h", ",", "3", ",", "\"\<\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)\>\""}], "}"}], ",", "0", ",", "n", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "t", ",", "3", ",", "\"\<\!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)\>\""}], "}"}], ",", "0", ",", "n", ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "u", ",", "1", ",", "\"\<\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)\>\""}], "}"}], ",", "0", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "v", ",", "1", ",", "\"\<\!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)\>\""}], "}"}], ",", "0", ",", "4"}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}]}], "Input", CellChangeTimes->{{3.398463567260326*^9, 3.398463599784747*^9}, { 3.39846363158537*^9, 3.3984636732936707`*^9}, {3.398463730374741*^9, 3.398463800570305*^9}, {3.398463836719531*^9, 3.398463845532794*^9}, { 3.3984639086067743`*^9, 3.398463931040599*^9}, {3.398463992143897*^9, 3.398464089849262*^9}, {3.398464146544834*^9, 3.398464226213574*^9}, { 3.3984650129192038`*^9, 3.398465139662683*^9}, {3.398465203943597*^9, 3.3984652118972816`*^9}, {3.398465333915621*^9, 3.398465349777776*^9}, { 3.3984654339029007`*^9, 3.3984654407295513`*^9}, {3.3984654796349907`*^9, 3.3984655151645727`*^9}, {3.398465658854896*^9, 3.398465665891231*^9}, { 3.398465724790063*^9, 3.398465796334157*^9}, {3.398465830720533*^9, 3.398465849571398*^9}, {3.398465881230691*^9, 3.39846588142741*^9}, { 3.3984660338494062`*^9, 3.3984660717617607`*^9}, {3.398466155522139*^9, 3.3984661582369432`*^9}, {3.3984662048831577`*^9, 3.398466219805749*^9}, { 3.398466267162321*^9, 3.398466270611307*^9}, {3.398466321868697*^9, 3.3984663875891123`*^9}, {3.398466467638206*^9, 3.3984665323415947`*^9}, { 3.3984665704235287`*^9, 3.3984665859667473`*^9}, {3.398466617626604*^9, 3.398466688691432*^9}, {3.398466735103437*^9, 3.398466842265193*^9}, { 3.39846695667279*^9, 3.398466974001977*^9}, {3.398467047093706*^9, 3.398467058161236*^9}, {3.3984680087639008`*^9, 3.398468009311473*^9}, { 3.398468747691346*^9, 3.3984687684910917`*^9}, {3.398468845795474*^9, 3.3984688529257097`*^9}, {3.3984688876717443`*^9, 3.39846895741355*^9}, { 3.39846909352887*^9, 3.398469122017425*^9}, {3.398517211411895*^9, 3.3985172463258677`*^9}}], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`h$$ = 3, $CellContext`t$$ = 3, $CellContext`u$$ = 3.615, $CellContext`v$$ = 1.485, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`h$$], 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)"}, 0, 20, 1}, {{ Hold[$CellContext`t$$], 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)"}, 0, 20, 1}, {{ Hold[$CellContext`u$$], 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)"}, 0, 4}, {{ Hold[$CellContext`v$$], 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)"}, 0, 4}}, Typeset`size$$ = {450., {70., 78.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`h$1038$$ = 0, $CellContext`t$1039$$ = 0, $CellContext`u$1040$$ = 0, $CellContext`v$1041$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`h$$ = 3, $CellContext`t$$ = 3, $CellContext`u$$ = 1, $CellContext`v$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`h$$, $CellContext`h$1038$$, 0], Hold[$CellContext`t$$, $CellContext`t$1039$$, 0], Hold[$CellContext`u$$, $CellContext`u$1040$$, 0], Hold[$CellContext`v$$, $CellContext`v$1041$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> GraphicsGrid[{{ Plot[ PDF[ BetaDistribution[$CellContext`u$$, $CellContext`v$$], \ $CellContext`\[Theta]], {$CellContext`\[Theta], 0, 1}, AxesLabel -> {"\[Theta]", "p(\[Theta])"}, PlotRange -> {{0, 1}, {0, Automatic}}, PlotLabel -> StringJoin["Prior:(\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)=", ToString[$CellContext`u$$], ", \!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)=", ToString[$CellContext`v$$], ")"]], Plot[{(1/(($CellContext`h$$/($CellContext`h$$ + \ $CellContext`t$$))^$CellContext`h$$ ( 1 - $CellContext`h$$/($CellContext`h$$ + \ $CellContext`t$$))^$CellContext`t$$)) $CellContext`\[Theta]^$CellContext`h$$ ( 1 - $CellContext`\[Theta])^$CellContext`t$$, PDF[ BetaDistribution[$CellContext`u$$ + $CellContext`h$$, \ $CellContext`v$$ + $CellContext`t$$], $CellContext`\[Theta]]/PDF[ BetaDistribution[$CellContext`u$$ + $CellContext`h$$, \ $CellContext`v$$ + $CellContext`t$$], ($CellContext`h$$ + $CellContext`u$$ - 1)/($CellContext`h$$ + $CellContext`u$$ + $CellContext`t$$ + \ $CellContext`v$$ - 2)]}, {$CellContext`\[Theta], 0, 1}, AxesLabel -> { "\[Theta]", "\[Proportional]P(\[Theta]|D),\[Proportional]P(D|\[Theta])"}, PlotStyle -> {{Red, Thickness[0.01]}, {Blue, Thickness[0.01]}}, PlotLabel -> StringJoin["(\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)=", ToString[$CellContext`h$$], ", \!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)=", ToString[$CellContext`t$$], ")"], PlotRange -> {{0, 1}, {0, 1}}]}}], "Specifications" :> {{{$CellContext`h$$, 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(H\)]\)"}, 0, 20, 1}, {{$CellContext`t$$, 3, "\!\(\*SubscriptBox[\(\[Alpha]\), \(T\)]\)"}, 0, 20, 1}, {{$CellContext`u$$, 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(H\)]\)"}, 0, 4}, {{$CellContext`v$$, 1, "\!\(\*SubscriptBox[\(\[Beta]\), \(T\)]\)"}, 0, 4}}, "Options" :> {}, "DefaultOptions" :> {}], ImageSizeCache->{494.5, {172., 178.5}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{ 3.398466221372216*^9, 3.39846627293544*^9, {3.398466334985178*^9, 3.398466359244781*^9}, 3.398466390218775*^9, {3.398466474364843*^9, 3.398466487877215*^9}, 3.398466536216983*^9, 3.398466595151919*^9, 3.398466690648636*^9, 3.3984667371585283`*^9, {3.398466804109009*^9, 3.398466818594983*^9}, 3.3984670598713093`*^9, 3.398467208853874*^9, 3.398468052914489*^9, 3.39846817157946*^9, {3.398468738464859*^9, 3.398468770709087*^9}, 3.398468854579842*^9, 3.398468891964505*^9, { 3.398468929206057*^9, 3.398468969352704*^9}, 3.398469014812305*^9, 3.398469053075158*^9, {3.398469115426852*^9, 3.398469122283939*^9}, { 3.3985172234758863`*^9, 3.3985172467582293`*^9}}], Cell[BoxData["\<\"Red is MLE, Blue is Bayesian\"\>"], "Print", CellChangeTimes->{ 3.398469123518071*^9, {3.3985172247120028`*^9, 3.39851724829674*^9}}] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{735, 604}, WindowMargins->{{41, Automatic}, {Automatic, 20}}, Magnification->1.25, FrontEndVersion->"6.0 for Mac OS X PowerPC (32-bit) (June 19, 2007)", StyleDefinitions->FrontEnd`FileName[{"Creative"}, "PastelColor.nb", CharacterEncoding -> "UTF-8"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 149, 2, 82, "Title"], Cell[742, 27, 100, 1, 32, "Text"], Cell[CellGroupData[{ Cell[867, 32, 203, 3, 38, "Subtitle"], Cell[1073, 37, 410, 7, 70, "Text"], Cell[1486, 46, 742, 11, 107, "Text"], Cell[2231, 59, 285, 7, 51, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2553, 71, 149, 2, 38, "Subtitle"], Cell[2705, 75, 695, 16, 51, "Text"], Cell[CellGroupData[{ Cell[3425, 95, 1784, 44, 166, "Input"], Cell[5212, 141, 2426, 49, 481, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[7687, 196, 105, 1, 38, "Subtitle"], Cell[7795, 199, 775, 18, 91, "Text"], Cell[CellGroupData[{ Cell[8595, 221, 1931, 48, 161, "Input"], Cell[10529, 271, 2636, 51, 481, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[13214, 328, 102, 1, 38, "Subtitle"], Cell[13319, 331, 933, 27, 72, "Text"], Cell[CellGroupData[{ Cell[14277, 362, 6960, 162, 581, "Input"], Cell[21240, 526, 5069, 98, 384, "Output"], Cell[26312, 626, 154, 2, 25, "Print"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)