Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: FindFit, Weibull

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92910] Re: FindFit, Weibull
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sat, 18 Oct 2008 06:24:51 -0400 (EDT)
  • References: <gd703r$i8a$1@smc.vnet.net>

On Oct 16, 2:04 am, P_ter <petervansumme... at gmail.com> 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

For parameters that must be positive, I routinely solve
for their logs, without constraints, and then exponentiate,
as in the following code. The values differ only trivially
from those that Darren got using constraints.

Block[{a,b}, {a,b} = {Exp@a,Exp@b} /. FindFit[praxis,
CDF[WeibullDistribution[Exp@a,Exp@b],x],{{a,0},{b,4}},{x}];
Plot[CDF[WeibullDistribution[a,b],x],{x,0,140}, Frame->True,
PlotRange->{-.0001,1}, Prolog->{PointSize[.02], Point/@praxis}];
{Norm[CDF[WeibullDistribution[a,b],praxis[[All,1]]] -
      praxis[[All,2]]], {a,b}}]

<<plot omitted>>

{0.0567336,{1.52052,77.4768}}

However, I have to wonder about your choice of a distribution.
Adding  a shift parameter, that for this data puts time-zero
some time before you started your clock, reduces the rms error
by 40%. Does this make any sense in terms of the problem?

Block[{a,b,c}, {a,b,c} = {Exp@a,Exp@b,c} /. FindFit[praxis,
CDF[WeibullDistribution[Exp@a,Exp@b],x+c],{{a,0},{b,4},{c,0}},{x}];
Plot[CDF[WeibullDistribution[a,b],x+c],{x,0,140}, Frame->True,
PlotRange->{-.0001,1}, Prolog->{PointSize[.02], Point/@praxis}];
{Norm[CDF[WeibullDistribution[a,b],praxis[[All,1]]+c] -
      praxis[[All,2]]], {a,b,c}}]

<<plot omitted>>

{0.0340676, {2.32031, 107.905, 28.9873}}


  • Prev by Date: Re: Re: Re: Nested If
  • Next by Date: Re: ListPlot Problem
  • Previous by thread: Re: FindFit, Weibull
  • Next by thread: Re: FindFit, Weibull