Re: Extract parameters from FIndFit output
- To: mathgroup at smc.vnet.net
- Subject: [mg107432] Re: Extract parameters from FIndFit output
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 12 Feb 2010 04:43:59 -0500 (EST)
On 2/11/10 at 5:20 AM, fjl3rd at mac.com (Frank Letkiewicz) wrote:
>Is it possible to extract the parameter values generated from
>FindFIt to use in other operations?
>For example:
>xvalues = {3, 5, 12, 47, 81, 112, 129, 186}; yvalues = {0.05, 0.10,
>0.25, 0.50, 0.75, 0.90, 0.95, 0.99}; data =
>Partition[Riffle[xvalues, yvalues], 2]; fitLogNormal = FindFit[data,
>CDF[LogNormalDistribution[=CE=BC, =CF=83], x], {=CE=BC, =CF=
=83}, x]
>Out[396]= {=CE=BC -> 3.47733, =CF=83 -> 1.19773}
>Can I extract these =CE=BC and =CF=83 values in the output as
>regular numbers?
Whenever you get a replacement rule, the most direct way to
extract the values is to use it with ReplaceAll (./). For example,
In[9]:= xvalues = {3, 5, 12, 47, 81, 112, 129, 186};
yvalues = {0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95, 0.99};
data = Partition[Riffle[xvalues, yvalues], 2];
fitLogNormal =
FindFit[data, CDF[LogNormalDistribution[m, s], x], {m, s}, x]
Out[12]= {m->3.47733,s->1.19773}
In[13]:= {m, s} /. fitLogNormal
Out[13]= {3.47733,1.19773}
Also, your method of combining xvalues and yvalues works but is
more complex than needed. Much simpler is
data=Transpose@{xvalues, yvalues};
=46or small data sets like you use here, there will be no
significant difference between what you did and using Transpose.
=46or very large data sets, Transpose will be faster.