Path: news.mathworks.com!not-for-mail
From: "Tom Lane" <tlane@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Fitting CDF of Beta distribution data
Date: Thu, 22 May 2008 11:26:14 -0400
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <g143am$sfm$1@fred.mathworks.com>
References: <g0v407$9e9$1@fred.mathworks.com> <g12lrt$lc2$1@fred.mathworks.com>
Reply-To: "Tom Lane" <tlane@mathworks.com>
NNTP-Posting-Host: lanet.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1211469974 29174 172.31.57.120 (22 May 2008 15:26:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 22 May 2008 15:26:14 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Xref: news.mathworks.com comp.soft-sys.matlab:469887



> It doesn't have to use the GLMFIT. Any function that can be
> used to estimate the parameters of beta distribution would do.

Okay, Pete.  Usually I tell people that they need to be clear about whether 
to approach something as a distribution fitting problem or a curve fitting 
problem.  Let's just say you have a curve fitting problem, which just 
happens to use a curve in the form of a distribution function.

Your largest x value is bigger than 1.  So the beta distribution on [0,1] is 
not appropriate.  Let's say you have a beta distribution with parameters A 
and B on the interval [0,C] where there are now three parameters to 
estimate.  Here's one way of going about that.  I exponentiated all the 
parameters just as a convenient way to force them to be positive.

I hope this is enough to get you started.

-- Tom

x = [0.1294;0.2211;0.3779;0.5559;0.7034;0.8901;1.1263;];
y = [0;0;0.004;0.007;0.029;0.078;0.192;];

f = @(p,x) betacdf(x/exp(p(1)),exp(p(2)),exp(p(3)));

p = nlinfit(x,y,f,[2 1 1])
fmt = 'Beta distributionon on [0,%g] with parameters %g and %g \n',...
t = sprintf(fmt, exp(p));

xx = linspace(0,1.2);
plot(x,y,'bo',xx,f(p,xx),'r-')
title(t)