Error when using custom pdf for mle

6 Ansichten (letzte 30 Tage)
Francesca
Francesca am 11 Jul. 2012
Hello,
I am trying to use the mle function with a custom pdf defined by:
function[frequency] = myfun(data,x) frequency = data.^(x);
myhandle = @(data, x) myfun(data,x)
My starting value for x is -1, so I enter: [phat] = mle (data, 'pdf', myhandle, 'start', -1);
(Physically, I have data where I the freqency of occurrence to be approximately inversely proportional to the energy signal observed.)
None of my data is negative or zero. However, I get the following error:
??? Error using ==> mlecustom>llf_pdfcdf at 441 The PDF function returned NaN or infinite values.
I have input my data into the defined function and checked that it does not produce any NaNs or infinities. Does anyone know how I can solve this error or a different way I can estimate my parameter x?
Thankyou!

Antworten (1)

Tom Lane
Tom Lane am 11 Jul. 2012
The mle function needs a real pdf. Yours isn't normalized to integrate to 1. Here's an example that integrates to 1 from 0 to +Inf for parameters a>1:
>> f = @(x,a) (a-1)*x.^-a;
>> quad(@(x) f(x,2),1,100)
ans =
0.9900
>> quad(@(x) f(x,5),1,100)
ans =
1.0000
>> quad(@(x) f(x,15),1,100)
ans =
1.0000
>> mle(x,'pdf',f,'start',2)
ans =
2.7134
  1 Kommentar
Francesca
Francesca am 11 Jul. 2012
Thanks! I understand what the problem is now. Sadly, I think (for physics reasons) that my exponent will be around -0.9. So maybe I will try defining a function with a cutoff to zero for high input so that it is normalizable?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by