Using mle function to fit cdf data
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!