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

 Respuesta aceptada

Torsten
Torsten el 30 de Mayo de 2023
Works for me (see above).

1 comentario

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 30 de Mayo de 2023

Comentada:

el 31 de Mayo de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by