# creating some smooth density functions

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\}$$

with

$$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.

• 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. – Rahul Oct 30 '13 at 5:01
• (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.) – Rahul Oct 30 '13 at 5:04
• @Rahul Narain :) thanks for the suggestion. – Seyhmus Güngören Oct 30 '13 at 7:58