How to generate a Frechet distribution using Methods of Moments?
Show older comments
How could I generate extreme value type II distribution for maximum using the method of moments? I think of something similar to this
Answers (1)
Jeff Miller
on 25 Jul 2023
%% Example for the 2-parameter Frechet distribution (minimum known to be 0)
% Make some example data to illustrate fitting commands.
sampleSize = 500;
observedVal = Frechet2(10,2).Random(sampleSize,1);
figure;
histogram(observedVal,'Normalization','pdf')
xvals = linspace(min(observedVal),max(observedVal),100);
% Fit with maximum likelihood:
fitDist = Frechet2(9,1); % Guess parameters 9,1
fitDist.EstML(observedVal)
fittedPDF = fitDist.PDF(xvals);
hold on
plot(xvals,fittedPDF)
% Fit with method of moments:
fitDist = Frechet2(9,1); % Guess parameters 9,1
obsMean = mean(observedVal);
obsVar = var(observedVal);
fitDist.EstMom([obsMean,obsVar])
fittedPDF = fitDist.PDF(xvals);
hold on
plot(xvals,fittedPDF)
legend('observed','MLE','Moment')
%% Example for the 3-parameter Frechet distribution (minimum a free paramenter)
% Make some example data to illustrate fitting commands.
%
sampleSize = 1000;
trueMin = -10;
observedVal = Frechet(10,2,trueMin).Random(sampleSize,1);
figure;
histogram(observedVal,'Normalization','pdf')
xvals = linspace(min(observedVal),max(observedVal),100);
% Fit with maximum likelihood:
fitDist = Frechet(9,1,-8); % Guess parameters 9,1,-2
fitDist.EstML(observedVal)
fittedPDF = fitDist.PDF(xvals);
hold on
plot(xvals,fittedPDF)
% Fit with method of moments
fitDist = Frechet(9,1,-8); % Guess parameters 9,1,-2
obsMean = mean(observedVal);
obsVar = var(observedVal);
obs3rdMom = mean( (observedVal - obsMean).^3 );
fitDist.EstMom([obsMean,obsVar,obs3rdMom])
fittedPDF = fitDist.PDF(xvals);
hold on
plot(xvals,fittedPDF)
legend('observed','MLE','Moment')
% Note that the parameter estimates will be unreasonable if the initial guesses
% for parameter values are too far wrong.
Categories
Find more on Structural Mechanics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!