Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Extracting parameters from NonlinearFit



Hi Jeff

suppose You have
myfit= 3.2*Exp[-0.5*t] 

than 
mfitpara= myfit /. a_*Exp[b_*t] :> {a,b}

will give You the desired parameters

Hope that helps
  Jens

> Recently I began writing a program to do a monte carlo simulation of an
> NMR experiment. The whole routine is attached (I hope that works.) The
> problem is this:
> I perform a NonlinearFit utilizing an exponential function of the form
> Exp[-a*x]. The nonlinear fit gives me back an equation, something like
> 1*E(-a*x). I want to extract the a parameter out of the equation and do
> two things with it. Because I am performing this simulation several
> (thousand) times, I want to know the standard deviation of the a
> parameters. Second, I would like to get an average of the terms
> (without having to use the last two lines of my code). If anyone out
> there could help me out, I would greatly appreciate it; I'm really
> stuck.
> 
> (PS, if you try to run my code, you may want to change the number of
> iterations to 10 or so. 10000 iterations takes a couple of hours.)
> 
> Jeff Wank
> Dept of Chemistry & Biochemistry
> University of Colorado at Boulder
> jrw@atlantis.colorado.edu
> (303) 492-8085
> 
> 
> (***********************************************************************
> 
>                     Mathematica-Compatible Notebook
> 
> This notebook can be used on any computer system with Mathematica 3.0,
> MathReader 3.0, or any compatible application. The data for the
> notebook  starts with the line of 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@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[      3390,         96]*)
> (*NotebookOutlinePosition[      4248,        126]*) (* 
> CellTagsIndexPosition[      4204,        122]*) (*WindowFrame->Normal*)
> 
> 
> Notebook[{
> 
> Cell[CellGroupData[{
> Cell["\<\
> 
> (*Begin Cell*)
> (*
> This routine takes a set of times, t, and fits a curve of the form \
> y=init*exp(-bx) 
> where b is the rate constant (lamda) *)\
> \>", "Input",
>   AspectRatioFixed->True],
> 
> Cell[CellGroupData[{
> 
> Cell[BoxData[{
>     \(Needs["\<Statistics`ContinuousDistributions`\>"]\), 
>     \(Needs["\<Statistics`NonlinearFit`\>"]\), 
>     \(Needs["\<Graphics`Colors`\>"]\), 
>     \(Clear[t, init, di, a, ndist, n, values, newlist, aone, lamda1,
> loga]\n
>     \n (*time\ values*) \), 
>     \(t = { .004,  .006,  .008,  .010,  .012,  .016,  .020,  .024, 
> .028}; \n
>     \n (*\ initial\ \((0\ time)\)\ value\ *) \ninit = 5.855\ 10\^7; \ \n
>     \n (*\ error\ in\ normalized\ intensity, \ 
>       as\ computed\ from\ 10\ ms\ data\ repetitions\ *) \ndi =  .00757;
> \n
>     \n (*a\ normal\ distribution\ of\ numbers\ *) \n
>     ndist = NormalDistribution[0, di\ init]; \n
>     \n (*\ initial\ value\ for\ lamda, \ the\ rate\ constant\ *) \n
>     lamda = 49.95; \n\n (*\ number\ of\ iterations\ *) \nn = 1; \n\n
>     a[i_, t_] := init\ Exp[\(-lamda\)\ t] + Random[ndist]; \n
>     values = \((a[#1, t]&)\)/@Table[i, {i, 1, n}]; \n
>     newlist = \((Transpose[{t, #1}]&)\)/@values; \n
>     \n (*fitting\ the\ data*) \n\n\t
>     lamda1\  = \ 
>       \((NonlinearFit[newlist[\([#]\)], init*Exp[\(-a\)*x], {x}, {a,
> c}]&)\)/@
>         Table[i, {i, 1, n}]; \n\n\tApply[Times, \ lamda1/init]\), 
>     \("\<divide the b term by n for your lambda\>"\)}], "Input",
>   AspectRatioFixed->True],
> 
> Cell[BoxData[
>     \(0.999999999999999822`\ E\^\(\(-52.4031624602439904`\)\ x\)\)],
> "Output"],
> 
> Cell[BoxData[
>     \("divide the b term by n for your lambda"\)], "Output"] }, Open  ]]
> }, Open  ]]
> },
> FrontEndVersion->"X 3.0",
> ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowToolbars->"RulerBar",
> CellGrouping->Manual,
> WindowSize->{779, 642},
> WindowMargins->{{172, Automatic}, {Automatic, 98}},
> PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}},
> ShowCellLabel->True,
> ShowCellTags->False,
> RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}
> ]
> 
> 
> (***********************************************************************
> 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[CellGroupData[{
> Cell[1731, 51, 195, 9, 102, "Input"],
> 
> Cell[CellGroupData[{
> Cell[1951, 64, 1239, 22, 540, "Input"], Cell[3193, 88, 92, 1, 28,
> "Output"], Cell[3288, 91, 74, 1, 27, "Output"]
> }, Open  ]]
> }, Open  ]]
> }
> ]
> *)
> 
> 
> 
> (***********************************************************************
> End of Mathematica Notebook file.
> ***********************************************************************)
> 
> 



  • Prev by Date: About ListPlot3D
  • Next by Date: RE: Values from InterpolatingFunction
  • Prev by thread: Extracting parameters from NonlinearFit
  • Next by thread: Re: Extracting parameters from NonlinearFit