|
lily, it sounds like maybe you are fitting a curve, not fitting a
distribution. See if this
<http://www.mathworks.com/products/statistics/examples.html?file=/products/demos/shipping/stats/cfitdfitdemo.html>
is of any help.
If you really are fitting a distribution, not a curve, and what you have
is in effect a histogram of values drawn from a distribution, and you
don't have access to the raw data, then gevfit isn't what you need.
What you can do is to define your own custom distribution that is a
"binned" version of the GEV, and use MLE to fit using that. But if you
have the raw data, you should use those.
On 8/9/2012 11:48 PM, lily wrote:
> Hi everyone,
> I have a problem in using command gevfit, Parmhat = gevfit(X), where X
> is the sample data of a distribution. What I have is the sample points
> x(such as -20:20) and corresponding probability distribution values y,
> and find both gevfit(y) and gevfit(x) will not get the right parameters.
> So, what is my main problem in using gevfit? Or deduce the new
> expression from the definition of gev function? Any suggestions are
> greatly appreciated.
>
> clear;clc;dbstop if error;
> x=linspace(-20,20,1000);
> k=0.5;mu=1;sigma=0;
> y=pdf('gev',x,k,mu,sigma);
> xquantile=icdf('gev',0.95,k,mu,sigma); %% calculate the quantile point
> of 0.95,that is x meeting P(X<=x)=0.95;
> x2=2*xquantile-x; %% make x=xquantile as symmetry
> axis;
> id1=x<=xquantile;id1=fliplr(id1);
> id2=x>xquantile;id2=fliplr(id2);
> y2=[y(id2) y(id1)]; %% x2 and y2 is the locations of
> new curve.
> figure(1);clf;
> plot(x,y,'-',x2,y2,'-*');
> parasf=gevfit(y2);
> y3=pdf('gev',y2,parasf(1),parasf(2),parasf(3));
> plot(x2,y3,'-d');hold off;
|