I would be tremendously grateful for help with this one:
I wrote a function that, for a given frequency distribution (observed data) that i call fbar, and a probability distribution function of the Laplace family with parameters mu and sigma, minimizes the Kullback-Leibler divergence.
Then I use Minimize[]
to find the KBD minimizing parameters mu and sigma.
When I did this for a very small (fake) dataset and a simple exponential function, the minimization gives a numerical value.
However, for the more complicated Laplace distribution and the larger dataset (200 entries), it only gives me {mu, sigma} as output, which is rather useless.
I attach the code, I am pretty sure, I did something wrong.
Laplace PDF:
laplace[x_, mu_, sigma_] := 1/(2*sigma) E^(-Abs[x - mu]/sigma)
KB Divergence:
KLlaplace[x_, mu_, sigma_] := Sum[If[fbar[[i]] == 0, 0,
laplace[x[[i]], mu, sigma] * Log[laplace[x[[i]], mu, sigma] fbar[[i]]]], {i, 1, 200}]
Minimization:
Minimize[KLlaplace[x, mu, sigma], {mu, sigma}]
Edit: x is just an interval between -.99 and 1 with 200 bins, so Laplace[ ] calculates the PDF for the corresponding bins. I am afraid, I would not know how to attach the fbar dataset. It is a list of 200 values, corresponding frequencies to 200 bins of the same domain.
LaplaceDistribution[]
is built-in? $\endgroup$x
? Does it have a fixed value or is it meant as further optimization variable? $\endgroup$