[Date Index]
[Thread Index]
[Author Index]
Re: FindFit, Weibull
*To*: mathgroup at smc.vnet.net
*Subject*: [mg92900] Re: [mg92868] FindFit, Weibull
*From*: Darren Glosemeyer <darreng at wolfram.com>
*Date*: Fri, 17 Oct 2008 05:25:03 -0400 (EDT)
*References*: <200810160904.FAA18690@smc.vnet.net>
P_ter wrote:
> I found some data which seemed to fit a WeibullDistribution. The data are:
> pr= {16, 34, 53, 75, 93, 120};
> After adding the median rank to the data:
> praxis={{16, 0.109101}, {34, 0.26445}, {53, 0.421407}, {75, 0.578593}, {93, 0.73555}, {120, 0.890899}};
> I checked with LeastSquares the parameters:
> \[Alpha]=1.4301;\[Beta] = 76.318.
> So far ok.
> But the following did not work:
> fit2 = {a, b} /. FindFit[praxis, CDF[WeibullDistribution[a, b], x], {a ,b}, {x}]
>
> So, I used the parameters in the Weibull CDF and the times from pr to get:
> praxis1= {{16, 0.106157}, {34, 0.27559}, {53, 0.451308}, {75, 0.623149}, {93, 0.73256}, {120, 0.848082}}
> (something went wrong with editing, so maybe I sent a by accident an unfinished message)
> I checked with FindFit and it worked. But then I gave extra some variations:
> praxis2 = {#, RandomReal[{0.95, 1.05}] CDF[WeibullDistribution[1.4, 76.318], #]} & /@ pr;
> fit4 = {a,b} /. FindFit[praxis2, CDF[WeibullDistribution[a,b], x], {a,b}, {x}]
> After a few times trying the two above lines FindFit did not work.
> It could be ok. But it seems to me that FindFit with a such a small relative variation in the data from 0.95 to 1.05 should still work.
> How can I use FindFit in the case of praxis in a safe way?
> Thanks in advance.
> P_ter
>
There are two problems I can see. First, a and b need to be constrained
to be positive. The FindFit::nrlnum message and failure happen because
the algorithm reaches a negative value of b, which results in complex
values.
Second, the default starting values of 1 for each parameter are far from
the optimum curve. With better non-default starting values a good result
can be obtained.
In[1]:= praxis = {{16, 0.109101}, {34, 0.26445}, {53, 0.421407}, {75,
0.578593}, {93, 0.73555}, {120, 0.890899}};
In[2]:= fit2 = FindFit[
praxis, {CDF[WeibullDistribution[a, b], x],
a > 0 && b > 0}, {{a, 1}, {b, 80}}, {x}]
Out[2]= {a -> 1.52051, b -> 77.4766}
Note that the result given is different from the least squares result
quoted in your message.
In[3]:= ls = {a -> 1.4301, b -> 76.318}
Out[3]= {a -> 1.4301, b -> 76.318}
If we check the sum of squared errors, we see that the FindFit result
gives a smaller value and so is a better fit in the sense of distance
from the cdf curve.
In[4]:= Map[((CDF[WeibullDistribution[a, b], #[[1]]] /. fit2) -
#[[2]])^2 &,
praxis] // Total
Out[4]= 0.0032187
In[5]:= Map[((CDF[WeibullDistribution[a, b], #[[1]]] /. ls) - #[[2]])^2 &,
praxis] // Total
Out[5]= 0.00426419
I suspect the least squares solution given solves a slightly different
problem, that is to say the condition for optimality for that solution
is probably something other than minimizing the sum of squared errors
from the cdf.
Darren Glosemeyer
Wolfram Research
Prev by Date:
**Re: FindFit, Weibull**
Next by Date:
**Re: What is the compatibility guide?**
Previous by thread:
**FindFit, Weibull**
Next by thread:
**Re: FindFit, Weibull**
| |