Problems with NonlinearFit
- To: mathgroup at smc.vnet.net
- Subject: [mg29578] Problems with NonlinearFit
- From: "guan koay" <cg_koay at hotmail.com>
- Date: Wed, 27 Jun 2001 05:12:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
hi there, I ran into some problems with NonlinearFit. Below are the data and error messages. Theoretically, the double sums should both go to infinity but 200 term for each sum should be enough. The test below is only using 4 instead of 200 term for each sum. I would to understand more about the error messages. Helps will be very much appreciated and I would like to thank you all in advance. Thank you. Attached here with the notebook(I have hard time saving it as html or text). Cheng Guan Koay cg_koay at berea.edu cg_koay at hotmail.com _________________________________________________________________ (*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info at wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 9951, 234]*) (*NotebookOutlinePosition[ 10633, 258]*) (* CellTagsIndexPosition[ 10589, 254]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ \(<< Statistics`NonlinearFit`\)], "Input"], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", StyleBox[\(FinalData3 := {{0, 1\/13488}, {1, 0}, {2, 1\/6744}, {3, 1\/1124}, {4, 13\/13488}, {5, 19\/6744}, {6, 55\/13488}, {7, 41\/6744}, {8, 5\/562}, {9, 179\/13488}, {10, 91\/4496}, {11, 299\/13488}, {12, 43\/1686}, {13, 439\/13488}, {14, 21\/562}, {15, 177\/4496}, {16, 545\/13488}, {17, 40\/843}, {18, 661\/13488}, {19, 749\/13488}, {20, 689\/13488}, {21, 46\/843}, {22, 341\/6744}, {23, 647\/13488}, {24, 653\/13488}, {25, 193\/4496}, {26, 34\/843}, {27, 503\/13488}, {28, 113\/3372}, {29, 445\/13488}, {30, 59\/2248}, {31, 157\/6744}, {32, 275\/13488}, {33, 39\/2248}, {34, 57\/4496}, {35, 67\/6744}, {36, 31\/3372}, {37, 97\/13488}, {38, 25\/3372}, {39, 65\/13488}, {40, 55\/13488}, {41, 37\/13488}, {42, 31\/13488}, {43, 13\/6744}, {44, 5\/4496}, {45, 1\/1686}, {46, 3\/4496}, {47, 1\/4496}, {48, 1\/13488}, {49, 5\/13488}, {50, 1\/4496}, {51, 5\/13488}, {52, 0}, {53, 1\/13488}, {54, 0}, {55, 1\/13488}, {56, 1\/13488}, {57, 1\/6744}, {58, 0}, {59, 0}, {60, 0}}\), "Text", FontFamily->"Times New Roman"]}]], "Input"], Cell[BoxData[{ \(\[IndentingNewLine]\[Sigma] := \(+\ at 1.57\)\), "\[IndentingNewLine]", \(\(\(\[Mu] := 3.767\)\(\[IndentingNewLine]\) \)\)}], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(NonlinearFit[ FinalData3, \[Sum]\+\(n = 1\)\%4\(\[Sum]\+\(r = d\)\%4\(\((\(r!\))\)\ \ \[Epsilon]\^d\ \((1 - \[Epsilon])\)\^\(r - d\)\ \[ExponentialE]\^\(-\(\((r\ \ - \ n\ \[Mu])\)\^2\/\(2\ n\ \[Sigma]\^2\)\)\)*\ \[Lambda]\^n\ \[ExponentialE]\ \^\(-\[Lambda]\)\)\/\(\((\(d!\))\)\ *\((\(\((r - d)\)!\)\ )\)*\@\(2 \[Pi]\ n\ \)*\ \[Sigma]\ *\((\(n!\))\)\)\), {d}, {{\[Lambda], 2.0, 14.0}, {\[Epsilon], 0.2, 0.8}}]\)\(\[IndentingNewLine]\) \)\)], "Input"], Cell[BoxData[ \(NSum::"nslim" \(\(:\)\(\ \)\) "Limit of summation \!\(#1\) is not a number."\)], "Message"], Cell[BoxData[ \(NSum::"nslim" \(\(:\)\(\ \)\) "Limit of summation \!\(#1\) is not a number."\)], "Message"], Cell[BoxData[ \(NSum::"nslim" \(\(:\)\(\ \)\) "Limit of summation \!\(#1\) is not a number."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(NSum :: \"nslim\"\) will be suppressed during \ this calculation."\)], "Message"], Cell[BoxData[ \(NSum::"nsnum" \(\(:\)\(\ \)\) "Summand (or its derivative) \ \!\(NSum[\(\(\(\(\(\[PartialD]\_\(\[Lambda]\)\) \(\(\(\(\(r !\)\)\\ \ \[Epsilon]\^#1\\ \((1 - \[Epsilon])\)\^\(r - #1\)\\ \(\(\[LeftSkeleton] 1 \ \[RightSkeleton]\)\)\\ \[Lambda]\^n\\ \[ExponentialE]\^\(-\[Lambda]\)\)\/\(\(\ \(#1 !\)\)\\ \(\(\(\((r - #1)\)\) !\)\)\\ \@\(2\\ \[Pi]\\ n\)\\ \[Sigma]\\ \(\ \(n !\)\)\)\)\)\)\), \(\(\[LeftSkeleton] 1 \[RightSkeleton]\)\), \(\({\(\ \[LeftSkeleton] 1 \[RightSkeleton]\)}\)\)\)\)]\) is not numerical at point \!\ \(n\) = \!\(4\)."\)], "Message"], Cell[BoxData[ \(NSum::"nsnum" \(\(:\)\(\ \)\) "Summand (or its derivative) \ \!\(NSum[\(\(\(\(\(\[PartialD]\_\(\[Lambda]\)\) \(\(\(0.318390601647988`\\ \(\ \(\[LeftSkeleton] 4 \[RightSkeleton]\)\)\\ \(\(r !\)\)\)\/\(\@n\\ \(\(n !\)\)\ \\ \(\(\(\((r - \(\(1.`\\ #1\)\))\)\) !\)\)\\ \(\(#1 !\)\)\)\)\)\)\), \(\(\ \[LeftSkeleton] 1 \[RightSkeleton]\)\), \(\({\(\[LeftSkeleton] 1 \ \[RightSkeleton]\)}\)\)\)\)]\) is not numerical at point \!\(n\) = \ \!\(4.`\)."\)], "Message"], Cell[BoxData[ \(NSum::"nsnum" \(\(:\)\(\ \)\) "Summand (or its derivative) \!\(NSum[\(\(\(\(\(\[PartialD]\_\(\ \[Epsilon]\)\) \(\(\(\(\(r !\)\)\\ \[Epsilon]\^#1\\ \((1 - \[Epsilon])\)\^\(r \ - #1\)\\ \(\(\[LeftSkeleton] 1 \[RightSkeleton]\)\)\\ \[Lambda]\^n\\ \ \[ExponentialE]\^\(-\[Lambda]\)\)\/\(\(\(#1 !\)\)\\ \(\(\(\((r - #1)\)\) \ !\)\)\\ \@\(2\\ \[Pi]\\ n\)\\ \[Sigma]\\ \(\(n !\)\)\)\)\)\)\), \(\(\ \[LeftSkeleton] 1 \[RightSkeleton]\)\), \(\({\(\[LeftSkeleton] 1 \ \[RightSkeleton]\)}\)\)\)\)]\) is not numerical at point \!\(n\) = \ \!\(4\)."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(NSum :: \"nsnum\"\) will be suppressed during \ this calculation."\)], "Message"], Cell[BoxData[ \(General::"ivar" \(\(:\)\(\ \)\) "\!\(10.`\) is not a valid variable."\)], "Message"], Cell[BoxData[ \(General::"ivar" \(\(:\)\(\ \)\) "\!\(10.`\) is not a valid variable."\)], "Message"], Cell[BoxData[ \(General::"ivar" \(\(:\)\(\ \)\) "\!\(10.`\) is not a valid variable."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(General :: \"ivar\"\) will be suppressed during \ this calculation."\)], "Message"], Cell[BoxData[ \(FindMinimum::"fqnum" \(\(:\)\(\ \)\) "Objective function or gradient is not real at \!\({\[Lambda], \ \[Epsilon]}\) = \!\({10.`, 0.6000000000000001`}\)."\)], "Message"], Cell[BoxData[ \(FindMinimum::"fqnum" \(\(:\)\(\ \)\) "Objective function or gradient is not real at \!\({\[Lambda], \ \[Epsilon]}\) = \!\({10.`, 0.6000000000000001`}\)."\)], "Message"], Cell[BoxData[ \(FindMinimum::"fqnum" \(\(:\)\(\ \)\) "Objective function or gradient is not real at \!\({\[Lambda], \ \[Epsilon]}\) = \!\({10.`, 0.6000000000000001`}\)."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(FindMinimum :: \"fqnum\"\) will be suppressed \ during this calculation."\)], "Message"], Cell[BoxData[ \(FindMinimum::"regex" \(\(:\)\(\ \)\) "Reached the point \!\({9.94216030759544`, 0.92360679775`}\) which is \ outside the region \!\({\(\({2.`, 14.`}\)\), \(\({0.2`, 0.8`}\)\)}\)."\)], \ "Message"], Cell[BoxData[ \(FindMinimum::"regex" \(\(:\)\(\ \)\) "Reached the point \!\({9.94216030759544`, 0.92360679775`}\) which is \ outside the region \!\({\(\({2.`, 14.`}\)\), \(\({0.2`, 0.8`}\)\)}\)."\)], \ "Message"], Cell[BoxData[ \(FindMinimum::"regex" \(\(:\)\(\ \)\) "Reached the point \!\({9.94216030759544`, 0.92360679775`}\) which is \ outside the region \!\({\(\({2.`, 14.`}\)\), \(\({0.2`, 0.8`}\)\)}\)."\)], \ "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(FindMinimum :: \"regex\"\) will be suppressed \ during this calculation."\)], "Message"], Cell[BoxData[ \(NonlinearFit::"fitfail" \(\(:\)\(\ \)\) "The fitting algorithm failed."\)], "Message"], Cell[BoxData[ \(NonlinearFit[{{0, 1\/13488}, {1, 0}, {2, 1\/6744}, {3, 1\/1124}, {4, 13\/13488}, {5, 19\/6744}, {6, 55\/13488}, {7, 41\/6744}, {8, 5\/562}, {9, 179\/13488}, {10, 91\/4496}, {11, 299\/13488}, {12, 43\/1686}, {13, 439\/13488}, {14, 21\/562}, {15, 177\/4496}, {16, 545\/13488}, {17, 40\/843}, {18, 661\/13488}, {19, 749\/13488}, {20, 689\/13488}, {21, 46\/843}, {22, 341\/6744}, {23, 647\/13488}, {24, 653\/13488}, {25, 193\/4496}, {26, 34\/843}, {27, 503\/13488}, {28, 113\/3372}, {29, 445\/13488}, {30, 59\/2248}, {31, 157\/6744}, {32, 275\/13488}, {33, 39\/2248}, {34, 57\/4496}, {35, 67\/6744}, {36, 31\/3372}, {37, 97\/13488}, {38, 25\/3372}, {39, 65\/13488}, {40, 55\/13488}, {41, 37\/13488}, {42, 31\/13488}, {43, 13\/6744}, {44, 5\/4496}, {45, 1\/1686}, {46, 3\/4496}, {47, 1\/4496}, {48, 1\/13488}, {49, 5\/13488}, {50, 1\/4496}, {51, 5\/13488}, {52, 0}, {53, 1\/13488}, {54, 0}, {55, 1\/13488}, {56, 1\/13488}, {57, 1\/6744}, {58, 0}, {59, 0}, {60, 0}}, \[Sum]\+\(n = 1\)\%4\(\[Sum]\+\(r = d\)\%4\(\( r!\)\ \ \[Epsilon]\^d\ \((1 - \[Epsilon])\)\^\(r - d\)\ \[ExponentialE]\^\(-\(\((r - \ n\ \[Mu])\)\^2\/\(2\ n\ \[Sigma]\^2\)\)\)\ \[Lambda]\^n\ \[ExponentialE]\^\(-\ \[Lambda]\)\)\/\(\(d!\)\ \(\((r - d)\)!\)\ \@\(2\ \[Pi]\ n\)\ \[Sigma]\ \ \(n!\)\)\), {d}, {{\[Lambda], 2.`, 14.`}, {\[Epsilon], 0.2`, 0.8`}}]\)], "Output"] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowSize->{568, 599}, WindowMargins->{{Automatic, 29}, {32, Automatic}}, CellLabelAutoDelete->True ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1717, 49, 60, 1, 30, "Input"], Cell[1780, 52, 1353, 21, 399, "Input"], Cell[3136, 75, 161, 3, 92, "Input"], Cell[CellGroupData[{ Cell[3322, 82, 497, 8, 109, "Input"], Cell[3822, 92, 118, 2, 24, "Message"], Cell[3943, 96, 118, 2, 24, "Message"], Cell[4064, 100, 118, 2, 24, "Message"], Cell[4185, 104, 163, 3, 42, "Message"], Cell[4351, 109, 577, 9, 88, "Message"], Cell[4931, 120, 484, 8, 84, "Message"], Cell[5418, 130, 578, 9, 88, "Message"], Cell[5999, 141, 163, 3, 42, "Message"], Cell[6165, 146, 111, 2, 24, "Message"], Cell[6279, 150, 111, 2, 24, "Message"], Cell[6393, 154, 111, 2, 24, "Message"], Cell[6507, 158, 165, 3, 42, "Message"], Cell[6675, 163, 195, 3, 42, "Message"], Cell[6873, 168, 195, 3, 42, "Message"], Cell[7071, 173, 195, 3, 42, "Message"], Cell[7269, 178, 170, 3, 42, "Message"], Cell[7442, 183, 223, 4, 42, "Message"], Cell[7668, 189, 223, 4, 42, "Message"], Cell[7894, 195, 223, 4, 42, "Message"], Cell[8120, 201, 170, 3, 42, "Message"], Cell[8293, 206, 113, 2, 24, "Message"], Cell[8409, 210, 1526, 21, 533, "Output"] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)