I would like to create some density functions based on some distance measure $D$. As a base density function lets say I have a Gaussian density $f$ with mean $-1$ and variance $1$. I would like to create some smooth and nice density functions $g$ randomly which are at least $\epsilon$ close to my base density $f$. The set of all possible densities can be written down as

$${\cal{F}}=\{g_0: D(g,f)\leq \epsilon\}$$


$$D(g,f)=\int_{-\infty}^\infty g(y)\log \left(\frac{g(y)}{f(y)}\right)\mathrm{d}y$$

and since $g$ are densities, we also have additionally

$$\int_{-\infty}^\infty g(y)\mathrm{d}y=1,\quad g(y)>0 \quad\forall y$$

How can I create such $g$ functions in Mathematica? is there a simple way?

Thank you very much for reading this post and thanks in advance for any help.

  • $\begingroup$ You could pick an arbitrary "smooth and nice" random function $h:\mathbb R\to\mathbb R$ and let $g(y) := f(y)\exp(\alpha h(y)+\beta)$. Then by choosing $\alpha$ sufficiently small and $\beta$ to satisfy $\int g(y)\,\mathrm dy=1$, you can get your desired properties. So the problem reduces to creating an arbitrary real-valued "smooth and nice" function. You are sampling from an infinite-dimensional function space, so you will probably have to narrow it down somehow. $\endgroup$ – Rahul Oct 30 '13 at 5:01
  • $\begingroup$ (Note that the expression for $D(f,g)$ becomes very simple with this approach. Unfortunately $D$ is not symmetric in $f$ and $g$, but if they are "close together" the difference should be small.) $\endgroup$ – Rahul Oct 30 '13 at 5:04
  • $\begingroup$ @Rahul Narain :) thanks for the suggestion. $\endgroup$ – Seyhmus Güngören Oct 30 '13 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.