Is it possible to have a function with the following properties?


(i) The function maps a bounded $n$-dimensional space $\mathcal{X}$ (say $\left[0,1\right]^n$) onto a bounded interval $\mathcal{Y}$ (say $\left[0,1\right]$);


(ii) The function has exactly $k$ minima in $X$, whose locations are distributed randomly, and whose vaues are distributed randomly over $\mathcal{Y}$. Ideally, the value of the global minimum (in $\mathcal{X}$) should correspond to the lowerbound of $\mathcal{Y}$.


Additional notes: 


(i) It does not matter if the function has additional minima outside of $\mathcal{X}$;


(ii) The function does not need to be differentiable over $\mathcal{X}$: this means that the local minima could also be, for example, kinks;


(iii) The number of maxima in $\mathcal{X}$ does not matter;


(iv) It is also OK if the minima and maxima are interchanged (i.e. if the function has $k$ maxima and any number of minima).



A Function with Exactly $k$ Minima in a Bounded Space
On $\mathbb{R}^{n}$ define $f(x)=e^{-\frac{1}{1-|x|^{2}}}$ for $|x|<1$ and $f(x)=0$ for $|x|\geq 1$. This is a smooth function with a maximum at the origin that vanishes outside of the unit ball. Given a point $a\in\mathbb{R}^{n}$ and $\epsilon>0$ define $g\_{a,\epsilon}(x)=f((x-a)/\epsilon)$ this has a single maximum at $a$ and vanishes outside of $B\_{\epsilon}(a)$. Given arbitrary distinct points $\{a\_{1},...,a\_{k}\}$ in $[0,1]^{n}$ and arbirary $r\_1,...,r\_k>0$ define $F(x)=\sum\_{i=1}^{k}r\_i\cdot g\_{a\_{i},\epsilon}(x)$ where $\epsilon=\min\_{i\neq j}(\{\frac{|a\_i-a\_j|}{2}\})$. Then the $B\_\epsilon(a\_i)$ are all pairwise disjoint so $F$ has exactly $k$ maxima.


