Using mle function to fit cdf data
4 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression 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!