Fitting Beta distribution

361 views
Skip to first unread message

SiliconValley

unread,
Sep 2, 2009, 12:52:17 PM9/2/09
to fityk-users
Has anyone tried to add to fityk the Beta distibution?
Thanks for your help!
mario

Marcin Wojdyr

unread,
Sep 2, 2009, 1:42:15 PM9/2/09
to fityk...@googlegroups.com
On Wed, Sep 2, 2009 at 18:52, SiliconValley<mva...@cscs.ch> wrote:
>
> Has anyone tried to add to fityk the Beta distibution?

I guess not, but this should be possible to do without changing the code:
http://www.unipress.waw.pl/fityk/ref.html#user-defined-functions-udf

I don't know what's the exact formula of the function you'd like to
have, but if Gamma functions is needed, you can use exp(lgamma(x))

Marcin

--
Marcin Wojdyr | http://www.unipress.waw.pl/~wojdyr/

SiliconValley

unread,
Sep 3, 2009, 5:43:09 AM9/3/09
to fityk-users
Thanks a lot, Marcin! I forgot to scan the function list to the end...

If I define my Beta function as dependent on height, alpha, beta, it
works, but values less than 1 can be assigned to alpha and beta
producing non realistic curves.
Is it possible to limit the search range to 1..Inf?

Another solution is to define a multi-statement function: compute
alpha and beta from center and fwhm. And then use the above equation
to compute the distribution.
Is it possible?

Thanks for your patience, I just started using fityk outside Gaussian
fitting...
mario

Marcin Wojdyr

unread,
Sep 3, 2009, 6:50:45 AM9/3/09
to fityk...@googlegroups.com
On Thu, Sep 3, 2009 at 11:43, SiliconValley<mva...@cscs.ch> wrote:

> If I define my Beta function as dependent on height, alpha, beta, it
> works, but values less than 1 can be assigned to alpha and beta
> producing non realistic curves.
> Is it possible to limit the search range to 1..Inf?

no, the only workaround is to replace alpha with e.g. 1+t^2

>
> Another solution is to define a multi-statement function: compute
> alpha and beta from center and fwhm. And then use the above equation
> to compute the distribution.
> Is it possible?

I'm not sure what you mean.
It's possible to define a function like this:
define ReadShockley(sigma0=1, a=1) = sigma0 * t * (a - ln(t)) where t=x*pi/180
but that's exactly the same as:
define ReadShockley(sigma0=1, a=1) = sigma0 * (x*pi/180) * (a - ln(x*pi/180))

SiliconValley

unread,
Sep 3, 2009, 9:12:03 AM9/3/09
to fityk-users
Thanks for the suggestions! Now it works (almost). Here is the Beta
distribution (I have used fwhm for variance):

define Beta(height=1, center=0.5, fwhm=0.05) = height*exp( lgamma
((center*((center*(1-center)/fwhm^2)-1))+((1-center)*((center*(1-
center)/fwhm^2)-1)))-lgamma((center*((center*(1-center)/fwhm^2)-1)))-
lgamma(((1-center)*((center*(1-center)/fwhm^2)-1))) )*x^((center*
((center*(1-center)/fwhm^2)-1))-1)*(1-x)^(((1-center)*((center*(1-
center)/fwhm^2)-1))-1)


There are only two problems remaining:
1) Sometimes the L-M fit outputs the message: "Error: In iteration 7:
trying to reverse singular matrix. Column 14 is zeroed". OK, could
happen. But the serious problem is that Fityk freezes and I should use
the Task manager to regain control.

2) There is a vertical line at zero for the fitted result that is
impossible to remove, and sometimes is the direct cause of the above
error. Seems that for my Beta function the data values should start
well above zero.

If you want, I can send you the data file and the .fit script.

Thanks!
mario

Marcin Wojdyr

unread,
Sep 3, 2009, 9:30:19 AM9/3/09
to fityk...@googlegroups.com
On Thu, Sep 3, 2009 at 15:12, SiliconValley<mva...@cscs.ch> wrote:

> There are only two problems remaining:
> 1) Sometimes the L-M fit outputs the message: "Error: In iteration 7:
> trying to reverse singular matrix. Column 14 is zeroed". OK, could
> happen. But the serious problem is that Fityk freezes and I should use
> the Task manager to regain control.

Yes, I've also seen this. That's a bug probably introduced in the
latest version, but I haven't investigated it yet.

> 2) There is a vertical line at zero for the fitted result that is
> impossible to remove

I look into this issue.

Marcin Wojdyr

unread,
Sep 3, 2009, 9:30:54 AM9/3/09
to fityk...@googlegroups.com
On Thu, Sep 3, 2009 at 15:12, SiliconValley<mva...@cscs.ch> wrote:

> There are only two problems remaining:
> 1) Sometimes the L-M fit outputs the message: "Error: In iteration 7:
> trying to reverse singular matrix. Column 14 is zeroed". OK, could
> happen. But the serious problem is that Fityk freezes and I should use
> the Task manager to regain control.

Yes, I've also seen this. That's a bug introduced in the latest


version, but I haven't investigated it yet.

> 2) There is a vertical line at zero for the fitted result that is
> impossible to remove

yes, that's another problem

Marcin Wojdyr

unread,
Sep 26, 2009, 9:32:39 AM9/26/09
to fityk-users
On Sep 3, 3:12 pm, SiliconValley <mva...@cscs.ch> wrote:

> 1) Sometimes the L-M fit outputs the message: "Error: In iteration 7:
> trying to reverse singular matrix. Column 14 is zeroed". OK, could
> happen. But the serious problem is that Fityk freezes and I should use
> the Task manager to regain control.

This should be fixed in r556.

Marcin
Reply all
Reply to author
Forward
0 new messages