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?
Frank L.
There are some strange characters in your post, so I can't read your
variable names, but if the iutput was something like {x->1, y->2} you
can get {1,2} by using ReplaceAll ( /. ):
{x,y} /. {x->1, y->2}
Cheers -- Sjoerd
On Feb 11, 1:14 pm, Frank Letkiewicz <fjl...@mac.com> 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, =C=
F=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 reg=
ular
> numbers?
>
> Frank L.
>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.
yvalues = {0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95, 0.99};
data = Thread[{xvalues, yvalues}];
You could also use Transpose in place of Thread
data == Transpose[{xvalues, yvalues}]
True
fitLogNormal = FindFit[data,
CDF[LogNormalDistribution[m, s], x],
{m, s}, x]
{m->3.47733,s->1.19773}
fitLogNormal is a list of replacement rules
m /. fitLogNormal
3.47733
fitLogNormal // First // Last
3.47733
Plot[
CDF[LogNormalDistribution[m, s], x] /.
fitLogNormal,
{x, 0, 200},
Epilog -> {Red, AbsolutePointSize[4], Point[data]},
PlotRange -> {0, 1}]
Bob Hanlon
---- Frank Letkiewicz <fjl...@mac.com> 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?
Frank L.
There are some strange characters in your mail, but say your parameters are
called mu and sd, then what you get is a list of rules:
In: fitLogNormal // FullForm
Out: List[Rule[mu, 3.4773291281865117`], Rule[b, 1.1977331975446315`]]
- The first element is a Rule
In: fitLogNormal[[1]] // FullForm
Out: Rule[mu, 3.4773291281865117`]
- You can get to any part of any expression by indexing, f.i.
In: fitLogNormal[[1]][[0]] (* equivalent to fitLogNormal[[1,0]] *)
Out: Rule
In: fitLogNormal[[1]][[1]]
Out: mu
In: fitLogNormal[[1,2]]
Out: 3.47733
- So the simplest way to get to your parameter values is probably:
In: fitLogNormal[[All, 2]]
Out: {3.47733, 1.19773}
Hope this helps, grtz Arnold