(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 14854, 485] NotebookOptionsPosition[ 12839, 408] NotebookOutlinePosition[ 13185, 423] CellTagsIndexPosition[ 13142, 420] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Incerteza na interpola\[CCedilla]\[ATilde]o e extrapola\[CCedilla]\ \[ATilde]o", "Title", CellChangeTimes->{{3.6242127564551*^9, 3.624212773206312*^9}}], Cell["um exemplo de constru\[CCedilla]\[ATilde]o de um package", "Text", CellChangeTimes->{{3.6242133257556925`*^9, 3.624213334475081*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"a0", "=", RowBox[{"-", "2.5"}]}], ";", " ", RowBox[{"b0", "=", "0.225"}], ";", RowBox[{"\[Sigma]i", "=", "0.3"}], ";"}], "\[IndentingNewLine]", RowBox[{"x", "=", RowBox[{"Range", "[", RowBox[{"4", ",", "24", ",", "4"}], "]"}]}]}], "Input", CellChangeTimes->{{3.624212783097642*^9, 3.624212870614581*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"4", ",", "8", ",", "12", ",", "16", ",", "20", ",", "24"}], "}"}]], "Output", CellChangeTimes->{{3.6242128330181284`*^9, 3.624212871192754*^9}, 3.624255554897457*^9, 3.6242557010514355`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"dado", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"RandomVariate", "[", " ", RowBox[{"NormalDistribution", "[", RowBox[{ RowBox[{"a0", "+", RowBox[{"b0", " ", RowBox[{"x", "[", RowBox[{"[", "i", "]"}], "]"}]}]}], ",", "\[Sigma]i"}], "]"}], " ", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "x", "]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.6242128856113973`*^9, 3.6242129434099207`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "1.7805642057525688`"}]}], "}"}], ",", RowBox[{"{", RowBox[{"8", ",", RowBox[{"-", "0.3469638522125066`"}]}], "}"}], ",", RowBox[{"{", RowBox[{"12", ",", "0.2361543812358853`"}], "}"}], ",", RowBox[{"{", RowBox[{"16", ",", "0.5990872294525186`"}], "}"}], ",", RowBox[{"{", RowBox[{"20", ",", "2.105985653544455`"}], "}"}], ",", RowBox[{"{", RowBox[{"24", ",", "3.0484711603731087`"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.624212944472497*^9, 3.6242140689898567`*^9, 3.6242555582992373`*^9, 3.6242557011139345`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ListPlot", "[", "dado", "]"}]], "Input", CellChangeTimes->{{3.6242129478321247`*^9, 3.6242129534106436`*^9}}], Cell[BoxData[ GraphicsBox[{{}, {{}, {RGBColor[0.368417, 0.506779, 0.709798], PointSize[0.019444444444444445`], AbsoluteThickness[1.6], PointBox[{{4., -1.7805642057525688`}, {8., -0.3469638522125066}, {12., 0.2361543812358853}, {16., 0.5990872294525186}, {20., 2.105985653544455}, {24., 3.0484711603731087`}}]}, {}}, {}}, AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], Axes->{True, True}, AxesLabel->{None, None}, AxesOrigin->{0, 0}, DisplayFunction->Identity, Frame->{{False, False}, {False, False}}, FrameLabel->{{None, None}, {None, None}}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, GridLines->{None, None}, GridLinesStyle->Directive[ GrayLevel[0.5, 0.4]], Method->{}, PlotRange->{{0, 24.}, {-1.7805642057525688`, 3.0484711603731087`}}, PlotRangeClipping->True, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.05], Scaled[0.05]}}, Ticks->{Automatic, Automatic}]], "Output", CellChangeTimes->{3.6242129540356884`*^9, 3.624255701270191*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"fit", "=", RowBox[{"LinearModelFit", "[", RowBox[{"dado", ",", RowBox[{"{", "z", "}"}], ",", "z", ",", RowBox[{"Weights", "\[Rule]", RowBox[{"1", "/", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"\[Sigma]i", "^", "2"}], ",", RowBox[{"Length", "[", "x", "]"}]}], " ", "]"}]}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.6242129782874317`*^9, 3.624213076973333*^9}, { 3.6242131079130683`*^9, 3.624213108756874*^9}}], Cell[BoxData[ TagBox[ RowBox[{"FittedModel", "[", TagBox[ PanelBox[ TagBox[ RowBox[{ RowBox[{"-", "2.543000758504776`"}], "+", RowBox[{"0.2276211299722565`", " ", "z"}]}], Short[#, 2]& ], FrameMargins->5], Editable -> False], "]"}], InterpretTemplate[ FittedModel[{ "Linear", {-2.543000758504776, 0.2276211299722565}, {{$CellContext`z}, {1, $CellContext`z}}, {0, 0}}, {{ 11.11111111111111, 11.11111111111111, 11.11111111111111, 11.11111111111111, 11.11111111111111, 11.11111111111111}}, {{4, -1.7805642057525688`}, { 8, -0.3469638522125066}, {12, 0.2361543812358853}, { 16, 0.5990872294525186}, {20, 2.105985653544455}, { 24, 3.0484711603731087`}}, {{1., 4.}, {1., 8.}, {1., 12.}, {1., 16.}, { 1., 20.}, {1., 24.}}, Function[Null, Internal`LocalizedBlock[{$CellContext`z}, #], {HoldAll}]]& ], Editable->False, SelectWithContents->True, Selectable->True]], "Output", CellChangeTimes->{{3.6242130178638926`*^9, 3.624213109553808*^9}, 3.6242140570515013`*^9, 3.6242555635496254`*^9, 3.624255701301442*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[Chi]2", "=", RowBox[{"Total", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"fit", "[", "\"\\"", "]"}], "/", "\[Sigma]i"}], ")"}], "^", "2"}], "]"}]}]], "Input", CellChangeTimes->{{3.6242130864583974`*^9, 3.624213158880863*^9}}], Cell[BoxData["4.895257082934279`"], "Output", CellChangeTimes->{3.62421315955278*^9, 3.6242555670654993`*^9, 3.624255701301442*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"v", "=", RowBox[{"fit", "[", "\"\\"", "]"}]}]], "Input", CellChangeTimes->{{3.6242131779398384`*^9, 3.624213185487259*^9}, { 3.6242132699730735`*^9, 3.6242132704731045`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0.09545751311721828`", ",", RowBox[{"-", "0.005507164218301058`"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "0.005507164218301057`"}], ",", "0.00039336887273579005`"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.6242131861279316`*^9, 3.624213271379421*^9, 3.6242555697688136`*^9, 3.624255701301442*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[Sigma]y", "=", RowBox[{"Sqrt", "[", " ", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "40"}], "}"}], ".", "v", ".", RowBox[{"{", RowBox[{"1", ",", "40"}], "}"}]}], " ", "]"}]}]], "Input", CellChangeTimes->{{3.6242132095202384`*^9, 3.6242132874587126`*^9}}], Cell[BoxData["0.5331740541609258`"], "Output", CellChangeTimes->{{3.624213254675389*^9, 3.624213287802476*^9}, 3.624255572956541*^9, 3.624255701317069*^9}] }, Open ]], Cell[CellGroupData[{ Cell["teste do package", "Section", CellChangeTimes->{{3.6242142409887433`*^9, 3.6242142474892087`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"SetDirectory", "[", " ", RowBox[{"NotebookDirectory", "[", "]"}], " ", "]"}]], "Input", CellChangeTimes->{{3.624255594098692*^9, 3.624255606130805*^9}}], Cell[BoxData["\<\"H:\\\\TEDFE_2014\\\\aulaMath\"\>"], "Output", CellChangeTimes->{3.624255606880868*^9, 3.624255701332699*^9}] }, Open ]], Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.624214265423806*^9, 3.6242142764714746`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "extrapolation`*"}]], "Input", CellChangeTimes->{{3.6242142550835075`*^9, 3.624214290191208*^9}}], Cell[BoxData[ DynamicModuleBox[{Typeset`open$$ = True}, PaneSelectorBox[{False-> RowBox[{ OpenerBox[Dynamic[Typeset`open$$], ImageSize->Small], StyleBox["extrapolation`", "InfoHeading"]}], True->GridBox[{ { RowBox[{ OpenerBox[Dynamic[Typeset`open$$], ImageSize->Small], StyleBox["extrapolation`", "InfoHeading"]}]}, {GridBox[{ { ButtonBox["simul", BaseStyle->"InformationLink", ButtonData:>{"Info3624248501-6803381", {"simul", "extrapolation`"}}, ButtonNote->"extrapolation`"], ButtonBox["value", BaseStyle->"InformationLink", ButtonData:>{"Info3624248501-6803381", {"value", "extrapolation`"}}, ButtonNote->"extrapolation`"], ButtonBox["\[Sigma]value", BaseStyle->"InformationLink", ButtonData:>{ "Info3624248501-6803381", {"\[Sigma]value", "extrapolation`"}}, ButtonNote->"extrapolation`"]} }, DefaultBaseStyle->"InfoGrid", GridBoxItemSize->{"Columns" -> {{ Scaled[0.31666666666666665`]}}}]} }, GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}}]}, Dynamic[Typeset`open$$], ImageSize->Automatic]]], "Print", "InfoCell", CellChangeTimes->{3.6242557013795733`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"f1", "=", RowBox[{"simul", "[", RowBox[{"a0", ",", "b0", ",", "x", ",", "\[Sigma]i"}], "]"}]}]], "Input", CellChangeTimes->{{3.6242142965822916`*^9, 3.624214313020977*^9}}], Cell[BoxData[ TagBox[ RowBox[{"FittedModel", "[", TagBox[ PanelBox[ TagBox[ RowBox[{ RowBox[{"-", "2.3833188010990036`"}], "+", RowBox[{"0.21891205693741533`", " ", "Private`z"}]}], Short[#, 2]& ], FrameMargins->5], Editable -> False], "]"}], InterpretTemplate[ FittedModel[{ "Linear", {-2.3833188010990036`, 0.21891205693741533`}, {{Private`z}, {1, Private`z}}, {0, 0}}, {{ 11.11111111111111, 11.11111111111111, 11.11111111111111, 11.11111111111111, 11.11111111111111, 11.11111111111111}}, {{4, -1.5006801837489843`}, { 8, -0.44661831100688143`}, {12, -0.13580952769102667`}, { 16, 1.559004864105195}, {20, 1.4771989723882366`}, { 24, 3.1356041621023296`}}, {{1., 4.}, {1., 8.}, {1., 12.}, {1., 16.}, { 1., 20.}, {1., 24.}}, Function[Null, Internal`LocalizedBlock[{Private`z}, #], {HoldAll}], VarianceEstimatorFunction -> (1& )]& ], Editable->False, SelectWithContents->True, Selectable->True]], "Output", CellChangeTimes->{3.6242143138647857`*^9, 3.6242556167362223`*^9, 3.6242557013951993`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"value", "[", RowBox[{"f1", ",", "40"}], "]"}]], "Input", CellChangeTimes->{{3.624214318237507*^9, 3.624214326425603*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"6.373163476397609`", ",", "7.889313092713509`"}], "}"}]], "Output", CellChangeTimes->{3.6242143270350165`*^9, 3.6242556198614407`*^9, 3.6242557014108295`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"u", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"value", "[", " ", RowBox[{ RowBox[{"simul", "[", RowBox[{"a0", ",", "b0", ",", "x", ",", "\[Sigma]i"}], "]"}], ",", "40"}], " ", "]"}], ",", RowBox[{"{", "1000", "}"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.624214334832451*^9, 3.6242143872054415`*^9}, 3.624255818003399*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Mean", "[", "u", "]"}]], "Input", CellChangeTimes->{{3.624214396737379*^9, 3.6242144039879*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"6.479103226956798`", ",", "3.9933975237589507`"}], "}"}]], "Output", CellChangeTimes->{3.624214404613062*^9, 3.624214598145645*^9, 3.624255702926561*^9, 3.6242558235350437`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"StandardDeviation", "[", " ", "u", " ", "]"}]], "Input", CellChangeTimes->{{3.624255739454934*^9, 3.62425574520535*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"0.4776215905263515`", ",", "2.9487475657767495`"}], "}"}]], "Output", CellChangeTimes->{3.624255745846019*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[Sigma]value", "[", RowBox[{"f1", ",", "40"}], "]"}]], "Input", CellChangeTimes->{{3.624255718849588*^9, 3.6242557305848017`*^9}}], Cell[BoxData["0.48196028289239173`"], "Output", CellChangeTimes->{3.624255731709882*^9, 3.624255890629253*^9}] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{989, 872}, WindowMargins->{{Automatic, 54}, {Automatic, 50}}, FrontEndVersion->"10.0 for Microsoft Windows (64-bit) (September 9, 2014)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 159, 2, 101, "Title"], Cell[742, 26, 140, 1, 30, "Text"], Cell[CellGroupData[{ Cell[907, 31, 360, 9, 52, "Input"], Cell[1270, 42, 238, 5, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[1545, 52, 659, 19, 31, "Input"], Cell[2207, 73, 677, 18, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[2921, 96, 134, 2, 31, "Input"], Cell[3058, 100, 1074, 27, 237, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[4169, 132, 503, 13, 31, "Input"], Cell[4675, 147, 1123, 29, 50, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[5835, 181, 297, 8, 31, "Input"], Cell[6135, 191, 135, 2, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[6307, 198, 223, 4, 31, "Input"], Cell[6533, 204, 414, 11, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[6984, 220, 306, 8, 31, "Input"], Cell[7293, 230, 160, 2, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7490, 237, 105, 1, 70, "Section"], Cell[CellGroupData[{ Cell[7620, 242, 180, 3, 31, "Input"], Cell[7803, 247, 127, 1, 31, "Output"] }, Open ]], Cell[7945, 251, 147, 2, 31, "Input"], Cell[CellGroupData[{ Cell[8117, 257, 126, 2, 31, "Input"], Cell[8246, 261, 1337, 36, 57, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[9620, 302, 204, 4, 31, "Input"], Cell[9827, 308, 1122, 30, 50, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10986, 343, 149, 3, 31, "Input"], Cell[11138, 348, 202, 4, 31, "Output"] }, Open ]], Cell[11355, 355, 425, 12, 31, "Input"], Cell[CellGroupData[{ Cell[11805, 371, 121, 2, 31, "Input"], Cell[11929, 375, 221, 4, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[12187, 384, 145, 2, 31, "Input"], Cell[12335, 388, 154, 4, 31, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[12526, 397, 159, 3, 31, "Input"], Cell[12688, 402, 111, 1, 31, "Output"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)