Using mle function to fit cdf data

7 visualizzazioni (ultimi 30 giorni)
Harvey
Harvey il 30 Ott 2015
Hi all,
I have test data (x and y values) that fall along a cdf plot. I want to fit these x and y values with a normcdf using the mle function in MATLAB. No matter what I've tried, I get an error. Help?
Here's the code that I'm using:
function phat = mle_test
%Test data
x = 1:100;
mu = 5;
sigma = 5;
y = normcdf(x,mu,sigma);
data = [x,y];
%Generate maximum likelihood estimate
phat = mle(x,'pdf',@pdf_norm,'cdf',@cdf_norm,'start',[5,5]);
%Plot raw data
plot(x,y,'o');
hold on
%Create fit
yfit = normcdf(x,phat(2),phat(1));
%Plot fitted data
plot(x,yfit,'r-')
function pdf_norm(x,mu)
sigma = 5;
normpdf(x,mu,sigma)
function cdf_norm(x,mu)
sigma = 5;
normcdf(x,mu,sigma)
Any help is greatly appreciated! Thanks!

Risposte (0)

Categorie

Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by