MATLAB Answers

## When does the kernel fitdist function returns nan?

Asked by Clarisha Nijman

### Clarisha Nijman (view profile)

on 24 Dec 2018
Latest activity Edited by madhan ravi

### madhan ravi (view profile)

on 25 Dec 2018
Dear all,
I am using the fitdist function in my code and notice that for some inputs I have a vector with nan entries.
This is the way I implement the code: pdf_x = fitdist(x,'Kernel','Kernel','epanechnikov');
So I wonder why? When does the a fitdistr kernel code return missing vallues? Can I have some feedback on this point?
thank you in advance.
Clarisha
I have the impression that it return a vector with missing values. Is that possible, pdLong = fitdist(NoAddLong,'Kernel','Kernel','epanechnikov');

the cyclist

### the cyclist (view profile)

on 24 Dec 2018
Can you upload MAT file with an example of the vector x that exhibits this behavior?
Clarisha Nijman

### Clarisha Nijman (view profile)

on 25 Dec 2018
Finally I was able to find one of the problematic situation: sum(f) equals zero, such that I cannot devide by zero. The sum of that probability distribution vector should equal one. So the question is now, why do I get a zero vector for pdf?
The code reads partially:
x=[0.294117647058824;0.352941176470588;0.529411764705882;0.588235294117647;0.588235294117647;0.470588235294118;0.588235294117647;0.529411764705882;0.125000000000000;0.375000000000000;0.562500000000000;0.625000000000000;0.625000000000000;0.500000000000000;0.125000000000000]
M=1000;
U = -M:1:M; %lijst met alle overgangen
NoAdd=x;
pd = fitdist(x,'Kernel','Kernel','epanechnikov');
f = pdf(pd,U);
prob=f/sum(f);

Sign in to comment.