How can I fit the parameters using mle with a self-defined function?

I 'm trying to fit the patameter of normal distribution using mle function I didn't use the built in function but with a self-defined function
Codes are as follows
clear;
clc;
f=@(x,mu,sigma) 1/sigma/sqrt(2*pi)*exp(-(x-mu).^2/2/sigma^2);
x=normrnd(0,1,[1000,1]);
pha=mle(x,'pdf',f,'Start',[0,1])
pha = 1×2
0.0346 1.0211
f is a function of the standard normal distribution I am using the mle function to fit the parameters but an error of "Numbers of input are not correct" happened I think a period of time but fail to find the soluition Can anyone help to solve this problem? Thanks

 채택된 답변

Torsten
Torsten 2023년 5월 30일

1 개 추천

Works for me (see above).

댓글 수: 1

Thanks It really works! Maybe I mistake something but anyway thanks for your response

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2023년 5월 30일

댓글:

2023년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by