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!