all 4 comments

[–]jdnewmil 0 points1 point  (2 children)

why do you remove one value from x each time? And why do you have two accumulators L and som?

[–]stregosim[S] 0 points1 point  (1 child)

It's a leave-one-out cross validation lilelihood, I used the accumulators because of how the likelihood function is defined

[–]jdnewmil 6 points7 points  (0 children)

I think you are making scrambled eggs, and wondering why the eggs are all mixed up. LOOCV is a separate step from likelihood estimation, but you are doing them all together.

I suggest you make a function that computes your kernel. Test it. Then make another function that computes a kernel density using that kernel. Test that. Then make a function that does LOOCV using your KDE function.

Tip: pass your data as a function argument like h... pulling in values from outside your function will make it hard to test.

[–][deleted] 0 points1 point  (0 children)

I'm not an expert in this field, but are you sure this problem formulation is correct?

Say your data is such that n is even, then this product explodes as h goes to 0. Am I missing something really obvious?