(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 9.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 49478, 1483] NotebookOptionsPosition[ 44357, 1331] NotebookOutlinePosition[ 44740, 1347] CellTagsIndexPosition[ 44697, 1344] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[" "], "Input", CellChangeTimes->{3.593773904693448*^9}], Cell[CellGroupData[{ Cell["\<\ M\[EAcute]todo da m\[AAcute]xima verossimilhan\[CCedilla]a no ajuste de uma \ reta, dados \[Distributed] Poisson\ \>", "Subtitle", CellChangeTimes->{{3.5931567226747637`*^9, 3.5931567678177023`*^9}, { 3.593793885447564*^9, 3.5937938933388453`*^9}, {3.673080223699567*^9, 3.673080240812219*^9}}], Cell[CellGroupData[{ Cell["\<\ Exemplo: espectro de energia em que o n\[UAcute]mero de contagens y(x) = a + \ b x, onde x \[EAcute] um n\[UAcute]mero inteiro, a ~1 e b~0\ \>", "Section", CellChangeTimes->{{3.593156781208995*^9, 3.593156864182005*^9}}], Cell[CellGroupData[{ Cell["\<\ Este \[EAcute] o conjunto de dados, tirado de um experimento e relocado por \ quest\[OTilde]es did\[AAcute]ticas\ \>", "Subsubsection", CellChangeTimes->{{3.5931568884645405`*^9, 3.593156925341392*^9}}], Cell[BoxData[ RowBox[{"dados", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"11", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"12", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"13", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"14", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"15", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"16", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"17", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"18", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"19", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"20", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"21", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"22", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"23", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"24", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"25", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"26", ",", "3"}], "}"}]}], "}"}]}]], "Input"], Cell[BoxData[ RowBox[{"ListPlot", "[", "dados", "]"}]], "Input", CellChangeTimes->{{3.5931572627493205`*^9, 3.5931572672183*^9}}], Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.5931572981730433`*^9, 3.5931573092517357`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"ErrorListPlotPoisson", "[", "data_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"u", ",", "t"}], "}"}], ",", RowBox[{ RowBox[{"u", "=", RowBox[{"N", "[", RowBox[{"Sqrt", "[", RowBox[{"data", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], " ", "]"}], " ", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"t", "=", RowBox[{"Partition", "[", " ", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{"dados", ",", RowBox[{"u", "/.", RowBox[{ RowBox[{"x_", "/;", RowBox[{"x", "<", "1"}]}], "\[Rule]", "1"}]}]}], "}"}], "]"}], " ", "]"}], ",", "3"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ErrorListPlot", "[", RowBox[{"t", " ", ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.593157380380357*^9, 3.5931574241638536`*^9}, 3.5931575670618114`*^9, {3.5931576374873*^9, 3.5931576424094377`*^9}, { 3.593158391244727*^9, 3.593158434528227*^9}, {3.5931586196315002`*^9, 3.593158648507949*^9}}], Cell[BoxData[ RowBox[{"ErrorListPlotPoisson", "[", "dados", "]"}]], "Input", CellChangeTimes->{{3.5931584387002864`*^9, 3.5931584439662075`*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["solu\[CCedilla]\[ATilde]o gr\[AAcute]fica", "Section", CellChangeTimes->{{3.59315696067132*^9, 3.593157079771192*^9}, 3.5931635883835726`*^9, {3.5931649897366996`*^9, 3.5931650054250293`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"logL", "[", RowBox[{"data_", ",", "a_", ",", "b_"}], "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"-", RowBox[{"Length", "[", "data", "]"}]}], "a"}], "-", RowBox[{ RowBox[{"Total", "[", RowBox[{"data", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], " ", "]"}], "b"}], "+", RowBox[{ RowBox[{"data", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], ".", RowBox[{"Log", "[", RowBox[{"a", "+", RowBox[{"b", "\[Times]", RowBox[{"data", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], " ", "]"}]}]}]}]], "Input", CellChangeTimes->{{3.593158794546671*^9, 3.593158938225933*^9}}], Cell[BoxData[ RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"logL", "[", RowBox[{"dados", ",", "a", ",", "b"}], "]"}], " ", "]"}], ",", RowBox[{"{", RowBox[{"a", ",", "2", ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{"b", ",", RowBox[{"-", "0.2"}], ",", "0"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.593158952695423*^9, 3.5931590649043255`*^9}, { 3.5931591141411953`*^9, 3.5931591205946827`*^9}}], Cell[BoxData[ RowBox[{"gradeLarga", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"a", ",", "b", ",", RowBox[{"logL", "[", RowBox[{"dados", ",", "a", ",", "b"}], "]"}]}], "}"}], " ", ",", RowBox[{"{", RowBox[{"a", ",", "4", ",", "6", ",", "0.4"}], "}"}], ",", RowBox[{"{", RowBox[{"b", ",", RowBox[{"-", "0.2"}], ",", RowBox[{"-", "0.05"}], ",", "0.03"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931609765464053`*^9, 3.593161059769416*^9}, { 3.5931610901303773`*^9, 3.5931610998339796`*^9}, {3.5931611837757874`*^9, 3.593161188666686*^9}, {3.593161225762311*^9, 3.593161229184367*^9}, { 3.5931613440808897`*^9, 3.5931613454091034`*^9}}], Cell[BoxData[ RowBox[{"gradeLarga", "//", "TableForm"}]], "Input", CellChangeTimes->{{3.5931612332783175`*^9, 3.5931612792963333`*^9}, { 3.593161320501542*^9, 3.5931613631443567`*^9}}], Cell[BoxData[ RowBox[{"Max", "[", " ", RowBox[{"Select", "[", " ", RowBox[{ RowBox[{ RowBox[{"Flatten", "[", RowBox[{"gradeLarga", ",", "1"}], "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "3"}], "]"}], "]"}], ",", RowBox[{ RowBox[{"#", " ", "\[Element]", " ", "Reals"}], "&"}]}], "]"}], " ", "]"}]], "Input", CellChangeTimes->{{3.5931613673164444`*^9, 3.593161373363652*^9}, { 3.5931614206629634`*^9, 3.59316154402864*^9}, {3.593161586171455*^9, 3.59316161336032*^9}}], Cell[BoxData[ RowBox[{"gradeMedia", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"a", ",", "b", ",", RowBox[{"logL", "[", RowBox[{"dados", ",", "a", ",", "b"}], "]"}]}], "}"}], " ", ",", RowBox[{"{", RowBox[{"a", ",", "4", ",", "4.8", ",", "0.2"}], "}"}], ",", RowBox[{"{", RowBox[{"b", ",", RowBox[{"-", "0.14"}], ",", RowBox[{"-", "0.08"}], ",", "0.01"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.593161672988388*^9, 3.5931617016930037`*^9}}], Cell[BoxData[ RowBox[{"TableForm", "[", "gradeMedia", "]"}]], "Input", CellChangeTimes->{{3.5931617082401915`*^9, 3.59316171441238*^9}}], Cell[BoxData[ RowBox[{"gradeFina", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"a", ",", "b", ",", RowBox[{"logL", "[", RowBox[{"dados", ",", "a", ",", "b"}], "]"}]}], "}"}], " ", ",", RowBox[{"{", RowBox[{"a", ",", "4.4", ",", "4.8", ",", "0.05"}], "}"}], ",", RowBox[{"{", RowBox[{"b", ",", RowBox[{"-", "0.13"}], ",", RowBox[{"-", "0.11"}], ",", "0.0025"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931617454608808`*^9, 3.593161782509653*^9}}], Cell[BoxData[ RowBox[{"TableForm", "[", "gradeFina", "]"}]], "Input", CellChangeTimes->{{3.59316179391646*^9, 3.5931617997605114`*^9}}], Cell["\<\ logL = m\[AAcute]ximo - n^2/2 corresponde a n desvios-padr\[OTilde]es quando \ h\[AAcute] s\[OAcute] uma vari\[AAcute]vel, aproximadamente\ \>", "Text", CellChangeTimes->{{3.593169863441961*^9, 3.5931698933184977`*^9}, { 3.673867517296339*^9, 3.6738675461677637`*^9}}], Cell[BoxData[ RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"logL", "[", RowBox[{"dados", ",", "a", ",", "b"}], "]"}], " ", "]"}], ",", RowBox[{"{", RowBox[{"a", ",", "0", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"b", ",", RowBox[{"-", "0.3"}], ",", "0.1"}], "}"}], ",", " ", RowBox[{"Contours", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"-", "4.5"}], ",", RowBox[{"-", "6"}], ",", RowBox[{"-", "8.5"}]}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.5931618629200306`*^9, 3.5931618829210577`*^9}, { 3.5931619181103554`*^9, 3.5931619271420584`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Solu\[CCedilla]\[ATilde]o anal\[IAcute]tica", "Section", CellChangeTimes->{{3.5931650217696047`*^9, 3.5931650253635273`*^9}}], Cell[BoxData[ RowBox[{"eqA", "=", RowBox[{ RowBox[{"Length", "[", "dados", "]"}], "\[Equal]", RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"(", RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], " ", ")"}]}], " ", "]"}]}]}]], "Input", CellChangeTimes->{{3.593162053164138*^9, 3.5931621249646997`*^9}, { 3.593162234892215*^9, 3.593162267472038*^9}}], Cell[BoxData[ RowBox[{"eqB", "=", RowBox[{ RowBox[{"Total", "[", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], " ", "]"}], "==", RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], "/", RowBox[{"(", RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], " ", ")"}]}]}], " ", "]"}]}]}]], "Input", CellChangeTimes->{{3.5931622734879436`*^9, 3.5931623419602594`*^9}}], Cell[BoxData[ RowBox[{"solucoes", "=", RowBox[{ RowBox[{"Solve", "[", RowBox[{ RowBox[{"{", RowBox[{"eqA", ",", "eqB"}], "}"}], ",", RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}]}], "]"}], "//", "N", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{ "Mathematica", " ", "tem", " ", "uma", " ", "representa\[CCedilla]\[ATilde]o", " ", "exata", " ", "para", " ", "estas", " ", "solu\[CCedilla]\[OTilde]es"}], ",", " ", RowBox[{ "porque", " ", "n\[ATilde]o", " ", "envolve", " ", "fun\[CCedilla]\[OTilde]es", " ", "transcendentes", " ", "em", " ", "ap", " ", "e", " ", "bp"}], ",", " ", RowBox[{ "mas", " ", "s\[ATilde]o", " ", "complicadas", " ", "demais", " ", "para", " ", "serem", " ", "\[UAcute]teis"}], ",", " ", RowBox[{ "por", " ", "isso", " ", "ficamos", " ", "com", " ", "as", " ", "solu\[CCedilla]\[OTilde]es", " ", "num\[EAcute]ricas"}]}], " ", "*)"}]}]}]], "Input", CellChangeTimes->{{3.5931623923221664`*^9, 3.593162394962927*^9}, { 3.5931624584037137`*^9, 3.5931624699980392`*^9}, {3.5931665157613773`*^9, 3.5931666367050905`*^9}, {3.593166676769606*^9, 3.593166681582386*^9}, { 3.6730808077309575`*^9, 3.6730808079306345`*^9}, {3.673886906609372*^9, 3.6738869167456694`*^9}}], Cell["\[EAcute] preciso selecionar as ra\[IAcute]zes que d\[ATilde]o logL \ real", "Text", CellChangeTimes->{{3.5931666550653877`*^9, 3.593166692020401*^9}}], Cell[BoxData[ RowBox[{"logLcalc", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"logL", "[", RowBox[{"dados", ",", "ap", ",", "bp"}], "]"}], "/.", RowBox[{"solucoes", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "solucoes", "]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.593162489030254*^9, 3.593162760372304*^9}}], Cell[BoxData[ RowBox[{"TableForm", "[", RowBox[{ RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{"solucoes", ",", "logLcalc"}], "}"}], "]"}], ",", RowBox[{"TableHeadings", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.593162740715046*^9, 3.593162825641287*^9}, { 3.593162926302703*^9, 3.5931629463506174`*^9}}], Cell["\<\ dessa tabela, verifica-se que solucoes[[7]] \[EAcute] a raiz - vamos guardar \ numa vari\[AAcute]vel para uso futuro\ \>", "Text", CellChangeTimes->{{3.5931667073961887`*^9, 3.5931667678993163`*^9}}], Cell[BoxData[ RowBox[{"solucao", "=", RowBox[{"solucoes", "[", RowBox[{"[", "7", "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.593166747632641*^9, 3.5931667561018343`*^9}}], Cell[BoxData[ RowBox[{"ErrorListPlotPoisson", "[", "dados", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"{", RowBox[{ RowBox[{"ErrorListPlotPoisson", "[", "dados", "]"}], ",", RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", "x"}]}], "/.", "solucao"}], ",", RowBox[{"{", RowBox[{"x", ",", "10", ",", "26"}], "}"}]}], "]"}]}], "}"}], "]"}]], "Input", CellChangeTimes->{{3.5931634767997212`*^9, 3.5931635266147757`*^9}, { 3.593166778509204*^9, 3.593166780509306*^9}}], Cell["\<\ agora, as barras de incerteza podem ser calculadas com uma \ aproxima\[CCedilla]\[ATilde]o melhor\ \>", "Text", CellChangeTimes->{{3.593166937908018*^9, 3.593166960924842*^9}, { 3.673867916822137*^9, 3.673867921940157*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"{", RowBox[{ RowBox[{"ErrorListPlot", "[", RowBox[{"Partition", "[", " ", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{"dados", ",", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], "]"}]}], "}"}], "]"}], "]"}], ",", "3"}], "]"}], " ", "]"}], ",", RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", "x"}]}], "/.", "solucao"}], ",", RowBox[{"{", RowBox[{"x", ",", "10", ",", "26"}], "}"}]}], "]"}]}], "}"}], "]"}]], "Input", CellChangeTimes->{{3.5931659714321547`*^9, 3.5931661282995806`*^9}, { 3.5931668038230305`*^9, 3.593166853872446*^9}}], Cell[BoxData[ RowBox[{"residuo", "=", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "-", RowBox[{"(", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], ")"}]}]}]], "Input", CellChangeTimes->{{3.59316697389423*^9, 3.5931669967235355`*^9}, { 3.59316715701301*^9, 3.593167160091282*^9}}], Cell[BoxData[ RowBox[{"residuo", "/", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], "]"}]}]], "Input"], Cell[CellGroupData[{ Cell["\<\ Sempre graficar os residuos normalizados em fun\[CCedilla]ao das \ vari\[AAcute]veis dependente e independente\ \>", "Subsubsection", CellChangeTimes->{{3.593167291254264*^9, 3.59316732067768*^9}}], Cell[BoxData[ RowBox[{"ListPlot", "[", " ", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], ",", RowBox[{"residuo", "/", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], "]"}]}]}], " ", "}"}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.5931670042864237`*^9, 3.593167055867215*^9}, { 3.5931670955411205`*^9, 3.5931671211986628`*^9}, {3.593167178685994*^9, 3.593167181107996*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"7", "/", "16"}], "//", "N"}]], "Input", CellChangeTimes->{{3.5931672010621367`*^9, 3.593167209093809*^9}}], Cell["usamos o valor ajustado para a coordenada independente", "Text", CellChangeTimes->{{3.5931673294124746`*^9, 3.593167350726077*^9}}], Cell[BoxData[ RowBox[{"ListPlot", "[", " ", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], ")"}], ",", RowBox[{"residuo", "/", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], "]"}]}]}], " ", "}"}], "]"}], "]"}]], "Input", CellChangeTimes->{3.5931672508928394`*^9}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ vari\[AHat]ncia a partir da matriz das derivadas da fun\[CCedilla]\[ATilde]o \ log(verossimilhan\[CCedilla]a) - exige o valor da estimativa!\ \>", "Subsection", CellChangeTimes->{{3.593774000045129*^9, 3.59377401093666*^9}, { 3.5937747739221787`*^9, 3.593774802721449*^9}}], Cell[BoxData[ RowBox[{"ycalc", "=", RowBox[{ RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}]}]], "Input", CellChangeTimes->{{3.5937929686525607`*^9, 3.593792972152852*^9}}], Cell[BoxData[ RowBox[{"matrixM", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"ycalc", "^", "2"}]}], "]"}], ",", RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], " ", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"ycalc", "^", "2"}]}]}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], " ", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"ycalc", "^", "2"}]}]}], "]"}], ",", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], "^", "2"}], " ", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"ycalc", "^", "2"}]}]}], "]"}]}], "}"}]}], " ", "}"}]}]], "Input", CellChangeTimes->{{3.59379299310772*^9, 3.5937930153126917`*^9}, { 3.593793064926193*^9, 3.59379314868316*^9}}], Cell[BoxData[ RowBox[{"varAB", "=", RowBox[{"Inverse", "[", "matrixM", "]"}]}]], "Input", CellChangeTimes->{{3.59379315535559*^9, 3.593793170341211*^9}}], Cell[BoxData[ RowBox[{"desvioPadrao", "=", RowBox[{"Round", "[", RowBox[{ RowBox[{"Sqrt", "[", RowBox[{"Diagonal", "[", "varAB", "]"}], " ", "]"}], ",", "0.01"}], "]"}]}]], "Input", CellChangeTimes->{{3.5937932047815757`*^9, 3.593793267208643*^9}}], Cell[BoxData["solucao"], "Input", CellChangeTimes->{{3.593793290976245*^9, 3.5937932918669443`*^9}}], Cell["Resultado: a = 4.6(16), b = -0.12(8)", "Text", CellChangeTimes->{{3.5937933028991113`*^9, 3.593793332510949*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["determina\[CCedilla]\[ATilde]o da tendenciosidade por simula\[CCedilla]\ \[ATilde]o", "Section", CellChangeTimes->{{3.593165046849037*^9, 3.5931650529587245`*^9}, { 3.5931673639611487`*^9, 3.5931673683675957`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"simul", "[", RowBox[{"a_", ",", "b_", ",", "x_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"RandomVariate", "[", RowBox[{"PoissonDistribution", "[", RowBox[{"a", "+", RowBox[{"b", " ", RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}]}]}], " ", "]"}], " ", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "x", "]"}]}], "}"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"dadosSimulados", "=", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{ RowBox[{"Range", "[", RowBox[{"11", ",", "26"}], "]"}], ",", RowBox[{"simul", "[", RowBox[{"4", ",", RowBox[{"-", "0.1"}], ",", RowBox[{"Range", "[", RowBox[{"11", ",", "26"}], "]"}]}], "]"}]}], "}"}], "]"}]}]], "Input", CellChangeTimes->{{3.593163610837818*^9, 3.593163628151218*^9}, { 3.5931637292189198`*^9, 3.5931637383600087`*^9}, {3.5931638604287586`*^9, 3.5931638925085535`*^9}}], Cell[CellGroupData[{ Cell["\<\ o m\[EAcute]todo anal\[IAcute]tico \[EAcute] mais indicado para repetir \ muitas vezes o c\[AAcute]lculo\ \>", "Subsection", CellChangeTimes->{{3.593167408463414*^9, 3.5931674435902367`*^9}}], Cell["equa\[CCedilla]\[OTilde]es de m\[AAcute]ximo da \ verossimilhan\[CCedilla]a", "Text", CellChangeTimes->{{3.593167457309688*^9, 3.593167467872733*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"eqAp", "[", "dados_", "]"}], ":=", RowBox[{ RowBox[{"Length", "[", "dados", "]"}], "\[Equal]", RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"(", RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], " ", ")"}]}], " ", "]"}]}]}]], "Input", CellChangeTimes->{{3.5931636701065164`*^9, 3.593163680075778*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"eqBp", "[", "dados_", "]"}], ":=", RowBox[{ RowBox[{"Total", "[", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], " ", "]"}], "==", RowBox[{"Total", "[", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], "/", RowBox[{"(", RowBox[{"ap", "+", RowBox[{"bp", " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], " ", ")"}]}]}], " ", "]"}]}]}]], "Input", CellChangeTimes->{{3.5931637076396923`*^9, 3.5931637135462456`*^9}}], Cell["resolve o sistema", "Text", CellChangeTimes->{{3.5931675013744307`*^9, 3.5931675270476446`*^9}}], Cell[BoxData[ RowBox[{"solucoes", "=", RowBox[{ RowBox[{"Solve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"eqAp", "[", "dadosSimulados", "]"}], ",", RowBox[{"eqBp", "[", "dadosSimulados", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}]}], "]"}], "//", "N", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"esse", " ", "//", RowBox[{ "N", " ", "transforma", " ", "em", " ", "n\[UAcute]merico", " ", "os", " ", "resultados", " ", "anal\[IAcute]ticos", " ", "encontrados", " ", "pelo", " ", "Mathematica"}]}], ",", " ", RowBox[{ RowBox[{ "uma", " ", "vez", " ", "que", " ", "as", " ", "equa\[CCedilla]\[OTilde]es", " ", "em", " ", "ap", " ", "e", " ", "bp", " ", "n\[ATilde]o", " ", "envolvem", " ", "nenhuma", " ", "fun\[CCedilla]\[ATilde]o", " ", "transcedente"}], " ", "-", " ", RowBox[{ "Mathematica", " ", "tem", " ", "uma", " ", "solu\[CCedilla]\[ATilde]o", " ", "exata", " ", "para", " ", "esse", " ", "caso"}]}], ",", " ", RowBox[{ "mas", " ", "que", " ", "\[EAcute]", " ", "complicada", " ", "demais", " ", "para", " ", "ser", " ", "\[UAcute]til"}]}], " ", "*)"}]}]}]], "Input", CellChangeTimes->{{3.5931637625643544`*^9, 3.593163783518556*^9}, { 3.5931675844255695`*^9, 3.593167704228587*^9}}], Cell[TextData[StyleBox["sele\[CCedilla]\[ATilde]o das ra\[IAcute]zes em duas \ etapas: primeiro isola as reais,", "Subsubsection"]], "Text", CellChangeTimes->{{3.593167744715065*^9, 3.593167778185503*^9}}], Cell[BoxData[ RowBox[{"logLcalc", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"logL", "[", RowBox[{"dadosSimulados", ",", "ap", ",", "bp"}], "]"}], "/.", RowBox[{"solucoes", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "solucoes", "]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931641629755583`*^9, 3.5931641643974752`*^9}}], Cell[BoxData[ RowBox[{"Select", "[", RowBox[{"logLcalc", ",", RowBox[{ RowBox[{"#", " ", "\[Element]", " ", "Reals"}], " ", "&"}]}], "]"}]], "Input", CellChangeTimes->{{3.5931639457768803`*^9, 3.5931640197650833`*^9}}], Cell["e depois separa a que d\[AAcute] o m\[AAcute]ximo de logL", "Text", CellChangeTimes->{{3.593167801717964*^9, 3.5931678170156164`*^9}}], Cell[BoxData[ RowBox[{"Position", "[", RowBox[{"logLcalc", ",", RowBox[{"Max", "[", RowBox[{"Select", "[", RowBox[{"logLcalc", ",", RowBox[{ RowBox[{"#", " ", "\[Element]", " ", "Reals"}], " ", "&"}]}], "]"}], " ", "]"}]}], " ", "]"}]], "Input", CellChangeTimes->{{3.593164023655876*^9, 3.593164059782732*^9}}], Cell[BoxData[ RowBox[{"solucoes", "[", RowBox[{"[", RowBox[{"Flatten", "[", RowBox[{"Position", "[", RowBox[{"logLcalc", ",", RowBox[{"Max", "[", RowBox[{"Select", "[", RowBox[{"logLcalc", ",", RowBox[{ RowBox[{"#", " ", "\[Element]", " ", "Reals"}], " ", "&"}]}], "]"}], " ", "]"}]}], " ", "]"}], " ", "]"}], " ", "]"}], "]"}]], "Input", CellChangeTimes->{{3.593164068845695*^9, 3.5931640863153734`*^9}}], Cell[CellGroupData[{ Cell["compacta toda a solu\[CCedilla]\[ATilde]o em uma \ fun\[CCedilla]\[ATilde]o", "Subsubsection", CellChangeTimes->{{3.5931678607678823`*^9, 3.5931678794875803`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"solve", "[", "dados_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"solucoes", ",", "logLcalc"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"solucoes", "=", RowBox[{ RowBox[{"Solve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"eqAp", "[", "dados", "]"}], ",", RowBox[{"eqBp", "[", "dados", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}]}], "]"}], "//", "N"}]}], ";", "\[IndentingNewLine]", RowBox[{"logLcalc", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"logL", "[", RowBox[{"dados", ",", "ap", ",", "bp"}], "]"}], "/.", RowBox[{"solucoes", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "solucoes", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"solucoes", "[", RowBox[{"[", RowBox[{"Flatten", "[", RowBox[{"Position", "[", RowBox[{"logLcalc", ",", RowBox[{"Max", "[", RowBox[{"Select", "[", RowBox[{"logLcalc", ",", RowBox[{ RowBox[{"#", " ", "\[Element]", " ", "Reals"}], " ", "&"}]}], "]"}], " ", "]"}]}], " ", "]"}], " ", "]"}], " ", "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.5931642353386135`*^9, 3.593164381611774*^9}, { 3.5931644174885902`*^9, 3.5931644344894896`*^9}}], Cell[BoxData[ RowBox[{"solve", "[", "dadosSimulados", "]"}]], "Input", CellChangeTimes->{{3.5931643858150845`*^9, 3.593164388690234*^9}, { 3.5931644463025637`*^9, 3.5931644476463847`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["prepara a simula\[CCedilla]\[ATilde]o", "Subsubsection", CellChangeTimes->{{3.593167905551422*^9, 3.593167908364054*^9}}], Cell["extrai as coordenadas x de interesse a partir dos dados", "Text", CellChangeTimes->{{3.5931679144894023`*^9, 3.593167927286912*^9}}], Cell[BoxData[ RowBox[{"xexp", "=", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.593164711394294*^9, 3.59316472612945*^9}}], Cell["\<\ \[EAcute] mais pr\[AAcute]tico criar uma fun\[CCedilla]\[ATilde]o que gera a \ tabela {x,y}, com y simulado \ \>", "Text", CellChangeTimes->{{3.5931679397563*^9, 3.593168003853361*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"simulDados", "[", RowBox[{"a_", ",", "b_", ",", "x_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"RandomVariate", "[", RowBox[{"PoissonDistribution", "[", RowBox[{"a", "+", RowBox[{"b", " ", RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}]}]}], " ", "]"}], " ", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "x", "]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.593164763209483*^9, 3.5931647840230513`*^9}}], Cell[BoxData[ RowBox[{"simulDados", "[", RowBox[{"4", ",", RowBox[{"-", "0.1"}], ",", "xexp"}], "]"}]], "Input", CellChangeTimes->{{3.593164792851598*^9, 3.593164803133374*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["simulando... ", "Subsection", CellChangeTimes->{{3.593168031917301*^9, 3.593168036995685*^9}}], Cell[BoxData["solucao"], "Input", CellChangeTimes->{{3.5931680917172146`*^9, 3.59316809240475*^9}}], Cell[BoxData[ RowBox[{"ap", "/.", "solucao"}]], "Input", CellChangeTimes->{{3.593168183721936*^9, 3.5931681870971184`*^9}}], Cell["\<\ come\[CCedilla]ar com 100 replicas e ir aumentando aos poucos, se h\[AAcute] \ tempo!\ \>", "Text", CellChangeTimes->{{3.5931682328182344`*^9, 3.5931682522254925`*^9}, 3.6730808917983713`*^9}], Cell[BoxData[ RowBox[{"replicas", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"solve", "[", RowBox[{"simulDados", "[", RowBox[{ RowBox[{"ap", "/.", "solucao"}], ",", RowBox[{"bp", "/.", "solucao"}], ",", "xexp"}], " ", "]"}], " ", "]"}], ",", RowBox[{"{", "100", "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931645899505596`*^9, 3.593164687674356*^9}, { 3.5931648109463053`*^9, 3.5931648401821833`*^9}, {3.593164873543248*^9, 3.5931648908566585`*^9}, {3.5931680562779045`*^9, 3.5931680724974856`*^9}, { 3.593168105202309*^9, 3.593168129703539*^9}, {3.593168191612974*^9, 3.593168198722703*^9}}], Cell[BoxData[ RowBox[{"Mean", "[", RowBox[{ RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}], "/.", "replicas"}], "]"}]], "Input", CellChangeTimes->{{3.5931648559485955`*^9, 3.5931648632146144`*^9}, { 3.5931649027791243`*^9, 3.5931649340932274`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"StandardDeviation", "[", RowBox[{ RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}], "/.", "replicas"}], "]"}], "/", RowBox[{"Sqrt", "[", "100", "]"}]}]], "Input", CellChangeTimes->{{3.593165093335798*^9, 3.59316510719586*^9}}], Cell["\<\ n\[ATilde]o d\[AAcute] para ter certeza que \[EAcute] tendencioso, valores \ conferem em menos que 2 desvios padroes... tentar 1000 repeticoes\ \>", "Text", CellChangeTimes->{{3.5931682672731256`*^9, 3.593168326619902*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"replicas", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"solve", "[", RowBox[{"simulDados", "[", RowBox[{"4.6", ",", RowBox[{"-", "0.115"}], ",", "xexp"}], " ", "]"}], " ", "]"}], ",", RowBox[{"{", "1000", "}"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.5931652129557066`*^9, 3.5931652281284018`*^9}, 3.593165322539451*^9}], Cell[BoxData[ RowBox[{"Mean", "[", RowBox[{ RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}], "/.", "replicas"}], "]"}]], "Input", CellChangeTimes->{{3.593165238082024*^9, 3.593165245269873*^9}}], Cell[BoxData[ RowBox[{"desvio", "=", RowBox[{"StandardDeviation", "[", RowBox[{ RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}], "/.", "replicas"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"desvio", "/", RowBox[{"Sqrt", "[", "1000", "]"}]}]], "Input", CellChangeTimes->{{3.5931652729588127`*^9, 3.5931653067886486`*^9}, 3.593165733888708*^9, {3.5931686707313275`*^9, 3.593168672106372*^9}}], Cell[BoxData[ RowBox[{"diferenca", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}], "/.", "solucao"}], ")"}], "-", RowBox[{"Mean", "[", RowBox[{ RowBox[{"{", RowBox[{"ap", ",", "bp"}], "}"}], "/.", "replicas"}], "]"}]}]}]], "Input", CellChangeTimes->{{3.5931685014413643`*^9, 3.593168616478546*^9}}], Cell["\<\ Conclus\[ATilde]o: parece que os par\[AHat]metros est\[ATilde]o ligeiramente \ superestimados, mas a tendenciosidade \[EAcute] muito menor que os \ desvios-padr\[OTilde]es do resultado, de modo que n\[ATilde]o vale a pena \ corrigir.\ \>", "Text", CellChangeTimes->{{3.5931686941856403`*^9, 3.59316876459552*^9}, { 3.593169924913869*^9, 3.593169928648432*^9}, 3.593773990309944*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Tendenciosidade muito menor que incerteza, resultado", "Section", CellChangeTimes->{{3.5931661769583254`*^9, 3.5931661881932735`*^9}, { 3.593168782268285*^9, 3.5931687837839785`*^9}, {3.673080915821656*^9, 3.6730809216811223`*^9}}], Cell["a = 4,6(17) e b = -0,12(8)", "Text", CellChangeTimes->{{3.5931662149915276`*^9, 3.5931662466493692`*^9}, { 3.593168792768838*^9, 3.5931687933001003`*^9}, {3.5931700606708293`*^9, 3.59317006103021*^9}, {3.5937940645249586`*^9, 3.5937940649312425`*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Comparando com MMQ, j\[AAcute] que a fun\[CCedilla]\[ATilde]o \[EAcute] \ linear", "Title", CellChangeTimes->{{3.5931688080821285`*^9, 3.593168822379716*^9}}], Cell["ESSENCIAL evitar pesos nulos no MMQ", "Text", CellChangeTimes->{{3.593168972324934*^9, 3.593168979747182*^9}}], Cell[BoxData[ RowBox[{"pesos", "=", RowBox[{"1", "/", RowBox[{"(", RowBox[{ RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "/.", RowBox[{ RowBox[{"x_", "/;", RowBox[{"x", "<", "1"}]}], "\[Rule]", "1"}]}], ")"}]}]}]], "Input", CellChangeTimes->{{3.593168881445238*^9, 3.5931688831797137`*^9}, { 3.593168934682357*^9, 3.593168958386692*^9}}], Cell[BoxData[ RowBox[{"mmqIncompleto", "=", RowBox[{"LinearModelFit", "[", RowBox[{"dados", ",", RowBox[{"{", "x", "}"}], ",", "x", ",", RowBox[{"Weights", "\[Rule]", "pesos"}], ",", RowBox[{"VarianceEstimatorFunction", "\[Rule]", RowBox[{"(", RowBox[{"1", "&"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931688307238855`*^9, 3.5931688763512373`*^9}, { 3.5931689837786236`*^9, 3.593169011420686*^9}}], Cell[BoxData[ RowBox[{"mmqIncompleto", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.5931690173272095`*^9, 3.593169026983966*^9}}], Cell[BoxData[ RowBox[{"abI", "=", RowBox[{ RowBox[{"mmqIncompleto", "[", "\"\\"", "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.5931691564593806`*^9, 3.5931691820075665`*^9}, { 3.593169219174505*^9, 3.593169232018936*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"{", RowBox[{ RowBox[{"ErrorListPlot", "[", RowBox[{"Partition", "[", " ", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{"dados", ",", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "1", "]"}], "]"}], "+", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "2", "]"}], "]"}], " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], "/.", "solucao"}], "]"}]}], "}"}], "]"}], "]"}], ",", "3"}], "]"}], " ", "]"}], ",", RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "1", "]"}], "]"}], "+", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "2", "]"}], "]"}], " ", "x"}]}], ",", RowBox[{"{", RowBox[{"x", ",", "9", ",", "26"}], "}"}]}], "]"}]}], "}"}], "]"}]], "Input", CellChangeTimes->{{3.5931692367223043`*^9, 3.5931693566346865`*^9}}], Cell["\<\ Esse resultado \[EAcute] muito ruim, mas ele vem da subestima\[CCedilla]\ \[ATilde]o da vari\[AHat]ncia por conta da assimetria da f.p. de Poisson. Por \ isso, fazemos outro ciclo...\ \>", "Text", CellChangeTimes->{{3.5931690374063773`*^9, 3.5931690949874763`*^9}}], Cell[BoxData[ RowBox[{"pesos", " ", "=", " ", RowBox[{"1", "/", RowBox[{"(", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "1", "]"}], "]"}], "+", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "2", "]"}], "]"}], " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], ")"}]}]}]], "Input", CellChangeTimes->{{3.5931690983938804`*^9, 3.5931691035347595`*^9}, { 3.593169381667215*^9, 3.59316938887074*^9}}], Cell[BoxData[ RowBox[{"mmqI1", "=", RowBox[{"LinearModelFit", "[", RowBox[{"dados", ",", RowBox[{"{", "x", "}"}], ",", "x", ",", RowBox[{"Weights", "\[Rule]", "pesos"}], ",", RowBox[{"VarianceEstimatorFunction", "\[Rule]", RowBox[{"(", RowBox[{"1", "&"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931694047465496`*^9, 3.5931694068560314`*^9}}], Cell["mudou muito - iterar outra vez, com novos pesos", "Text", CellChangeTimes->{{3.5931694367794247`*^9, 3.5931694469205685`*^9}}], Cell[BoxData[ RowBox[{"abI", "=", RowBox[{ RowBox[{"mmqI1", "[", "\"\\"", "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.5931694649371395`*^9, 3.5931694674997616`*^9}}], Cell[BoxData[ RowBox[{"pesos", " ", "=", " ", RowBox[{"1", "/", RowBox[{"(", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "1", "]"}], "]"}], "+", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "2", "]"}], "]"}], " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], ")"}]}]}]], "Input"], Cell[BoxData[ RowBox[{"mmqI2", "=", RowBox[{"LinearModelFit", "[", RowBox[{"dados", ",", RowBox[{"{", "x", "}"}], ",", "x", ",", RowBox[{"Weights", "\[Rule]", "pesos"}], ",", RowBox[{"VarianceEstimatorFunction", "\[Rule]", RowBox[{"(", RowBox[{"1", "&"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.593169485203786*^9, 3.5931694852819123`*^9}}], Cell["mais uma itera\[CCedilla]\[ATilde]o ...", "Text", CellChangeTimes->{{3.5931695812087126`*^9, 3.5931695909123354`*^9}}], Cell[BoxData[ RowBox[{"abI", "=", RowBox[{ RowBox[{"mmqI2", "[", "\"\\"", "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.593169516174125*^9, 3.5931695162678986`*^9}}], Cell[BoxData[ RowBox[{"mmqI3", "=", RowBox[{"LinearModelFit", "[", RowBox[{"dados", ",", RowBox[{"{", "x", "}"}], ",", "x", ",", RowBox[{"Weights", "\[Rule]", RowBox[{"1", "/", RowBox[{"(", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "1", "]"}], "]"}], "+", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "2", "]"}], "]"}], " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], ")"}]}]}], ",", RowBox[{"VarianceEstimatorFunction", "\[Rule]", RowBox[{"(", RowBox[{"1", "&"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{ 3.593169536159521*^9, {3.5931696125384445`*^9, 3.593169612647845*^9}}], Cell["uma \[UAcute]ltima itera\[CCedilla]\[ATilde]o, por desencargo de consci\ \[EHat]ncia...", "Text", CellChangeTimes->{3.5931695738177032`*^9}], Cell[BoxData[ RowBox[{"abI", "=", RowBox[{ RowBox[{"mmqI3", "[", "\"\\"", "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.593169564723508*^9, 3.593169568645568*^9}, { 3.5931696057412167`*^9, 3.5931696166949263`*^9}}], Cell[BoxData[ RowBox[{"mmq", "=", RowBox[{"LinearModelFit", "[", RowBox[{"dados", ",", RowBox[{"{", "x", "}"}], ",", "x", ",", RowBox[{"Weights", "\[Rule]", RowBox[{"1", "/", RowBox[{"(", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "1", "]"}], "]"}], "+", RowBox[{ RowBox[{"abI", "[", RowBox[{"[", "2", "]"}], "]"}], " ", RowBox[{"dados", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], ")"}]}]}], ",", RowBox[{"VarianceEstimatorFunction", "\[Rule]", RowBox[{"(", RowBox[{"1", "&"}], ")"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.5931696311487923`*^9, 3.593169631320676*^9}}], Cell[BoxData[ RowBox[{"mmq", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.593169647805869*^9, 3.593169655306281*^9}}], Cell["\<\ compare com resultado da m\[AAcute]xima verossimilhan\[CCedilla]a: a = \ 4,6(17) e b = -0,12(9)\ \>", "Text", CellChangeTimes->{{3.5931696720102654`*^9, 3.5931696886829967`*^9}, { 3.5931700497015014`*^9, 3.5931700501390424`*^9}}], Cell["\<\ Assim, NESTE caso em que a fun\[CCedilla]\[ATilde]o \[EAcute] linear nos par\ \[AHat]metros, o mmq se sai muito bem, DESDE QUE se refa\[CCedilla]a os c\ \[AAcute]lculos com pesos deduzidos dos valores ajustados, em um processo \ iterativo, at\[EAcute] a converg\[EHat]ncia. Usar Sqrt[ n experimental ] para \ o desvio-padr\[ATilde]o de uma grandeza com f.p. Poisson \[EAcute] uma \ aproxima\[CCedilla]\[ATilde]o inadequada quando n < 10 e muito ruim quando n \ ~ 1.\ \>", "Text", CellChangeTimes->{{3.5931697084808683`*^9, 3.5931698299714966`*^9}, { 3.5931699403833914`*^9, 3.5931700372165065`*^9}}] }, Open ]] }, WindowSize->{1350, 904}, WindowMargins->{{0, Automatic}, {Automatic, 11}}, Magnification->1.4000000953674316`, 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[557, 20, 69, 1, 43, "Input"], Cell[CellGroupData[{ Cell[651, 25, 310, 6, 77, "Subtitle"], Cell[CellGroupData[{ Cell[986, 35, 231, 4, 152, "Section"], Cell[CellGroupData[{ Cell[1242, 43, 213, 4, 54, "Subsubsection"], Cell[1458, 49, 1072, 35, 72, "Input"], Cell[2533, 86, 131, 2, 43, "Input"], Cell[2667, 90, 149, 2, 43, "Input"], Cell[2819, 94, 1274, 33, 100, "Input"], Cell[4096, 129, 147, 2, 43, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[4292, 137, 203, 2, 96, "Section"], Cell[4498, 141, 759, 24, 43, "Input"], Cell[5260, 167, 473, 12, 43, "Input"], Cell[5736, 181, 734, 17, 43, "Input"], Cell[6473, 200, 188, 3, 43, "Input"], Cell[6664, 205, 524, 14, 43, "Input"], Cell[7191, 221, 534, 14, 43, "Input"], Cell[7728, 237, 138, 2, 43, "Input"], Cell[7869, 241, 538, 14, 43, "Input"], Cell[8410, 257, 137, 2, 43, "Input"], Cell[8550, 261, 281, 5, 42, "Text"], Cell[8834, 268, 661, 18, 43, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[9532, 291, 132, 1, 96, "Section"], Cell[9667, 294, 585, 17, 43, "Input"], Cell[10255, 313, 748, 23, 43, "Input"], Cell[11006, 338, 1328, 30, 100, "Input"], Cell[12337, 370, 158, 2, 42, "Text"], Cell[12498, 374, 441, 12, 43, "Input"], Cell[12942, 388, 481, 13, 43, "Input"], Cell[13426, 403, 210, 4, 42, "Text"], Cell[13639, 409, 182, 4, 43, "Input"], Cell[13824, 415, 77, 1, 43, "Input"], Cell[13904, 418, 498, 14, 43, "Input"], Cell[14405, 434, 236, 5, 42, "Text"], Cell[14644, 441, 1004, 29, 72, "Input"], Cell[15651, 472, 493, 15, 43, "Input"], Cell[16147, 489, 269, 9, 43, "Input"], Cell[CellGroupData[{ Cell[16441, 502, 208, 4, 54, "Subsubsection"], Cell[16652, 508, 696, 19, 43, "Input"], Cell[17351, 529, 142, 3, 43, "Input"], Cell[17496, 534, 138, 1, 42, "Text"], Cell[17637, 537, 708, 22, 43, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[18382, 564, 286, 5, 67, "Subsection"], Cell[18671, 571, 298, 9, 43, "Input"], Cell[18972, 582, 1554, 47, 72, "Input"], Cell[20529, 631, 158, 3, 43, "Input"], Cell[20690, 636, 271, 7, 43, "Input"], Cell[20964, 645, 101, 1, 43, "Input"], Cell[21068, 648, 120, 1, 42, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[21237, 655, 223, 3, 96, "Section"], Cell[21463, 660, 483, 14, 43, "Input"], Cell[21949, 676, 548, 14, 43, "Input"], Cell[CellGroupData[{ Cell[22522, 694, 202, 4, 67, "Subsection"], Cell[22727, 700, 157, 2, 42, "Text"], Cell[22887, 704, 571, 17, 43, "Input"], Cell[23461, 723, 783, 24, 43, "Input"], Cell[24247, 749, 103, 1, 42, "Text"], Cell[24353, 752, 1399, 32, 128, "Input"], Cell[25755, 786, 206, 2, 57, "Text"], Cell[25964, 790, 454, 12, 43, "Input"], Cell[26421, 804, 234, 6, 43, "Input"], Cell[26658, 812, 141, 1, 42, "Text"], Cell[26802, 815, 349, 9, 43, "Input"], Cell[27154, 826, 477, 12, 43, "Input"], Cell[CellGroupData[{ Cell[27656, 842, 170, 2, 54, "Subsubsection"], Cell[27829, 846, 1707, 47, 156, "Input"], Cell[29539, 895, 192, 3, 43, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[29768, 903, 128, 1, 54, "Subsubsection"], Cell[29899, 906, 139, 1, 42, "Text"], Cell[30041, 909, 200, 5, 43, "Input"], Cell[30244, 916, 196, 4, 42, "Text"], Cell[30443, 922, 685, 20, 43, "Input"], Cell[31131, 944, 186, 4, 43, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[31366, 954, 101, 1, 67, "Subsection"], Cell[31470, 957, 100, 1, 43, "Input"], Cell[31573, 960, 125, 2, 43, "Input"], Cell[31701, 964, 207, 5, 42, "Text"], Cell[31911, 971, 660, 15, 43, "Input"], Cell[32574, 988, 262, 6, 43, "Input"], Cell[32839, 996, 276, 7, 43, "Input"], Cell[33118, 1005, 234, 4, 42, "Text"], Cell[33355, 1011, 414, 11, 43, "Input"], Cell[33772, 1024, 205, 5, 43, "Input"], Cell[33980, 1031, 183, 5, 43, "Input"], Cell[34166, 1038, 232, 4, 43, "Input"], Cell[34401, 1044, 384, 12, 43, "Input"], Cell[34788, 1058, 396, 7, 70, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[35233, 1071, 243, 3, 96, "Section"], Cell[35479, 1076, 265, 3, 42, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[35793, 1085, 165, 2, 141, "Title"], Cell[35961, 1089, 117, 1, 42, "Text"], Cell[36081, 1092, 424, 12, 43, "Input"], Cell[36508, 1106, 450, 10, 43, "Input"], Cell[36961, 1118, 155, 2, 43, "Input"], Cell[37119, 1122, 318, 7, 43, "Input"], Cell[37440, 1131, 1200, 35, 72, "Input"], Cell[38643, 1168, 276, 5, 70, "Text"], Cell[38922, 1175, 496, 14, 43, "Input"], Cell[39421, 1191, 391, 9, 43, "Input"], Cell[39815, 1202, 133, 1, 42, "Text"], Cell[39951, 1205, 261, 6, 43, "Input"], Cell[40215, 1213, 378, 12, 43, "Input"], Cell[40596, 1227, 389, 9, 43, "Input"], Cell[40988, 1238, 125, 1, 42, "Text"], Cell[41116, 1241, 259, 6, 43, "Input"], Cell[41378, 1249, 758, 21, 43, "Input"], Cell[42139, 1272, 147, 2, 42, "Text"], Cell[42289, 1276, 310, 7, 43, "Input"], Cell[42602, 1285, 731, 20, 43, "Input"], Cell[43336, 1307, 143, 2, 43, "Input"], Cell[43482, 1311, 244, 5, 42, "Text"], Cell[43729, 1318, 612, 10, 97, "Text"] }, Open ]] } ] *)