Using mle function to fit cdf data
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!