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 件のコメント

jianyu WANG
jianyu WANG 2023 年 5 月 31 日
Thanks It really works! Maybe I mistake something but anyway thanks for your response

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

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