This problem is distilled from one arising in a study of complex random variables, but I've removed as much baggage as I can without (I hope) making it trivial.
Fix $D>0$. A function $f:\mathbb R\to\mathbb R$ is $D$-basic if there are $x_1,x_2\in\mathbb R$ and $p_1,p_2\ge 0$ such that $|x_1-x_2|\le D$, $f(x_1)=p_1$, $f(x_2)=p_2$, $f(x)=0$ for $x\notin\lbrace x_1,x_2\rbrace$, and $p_1x_1+p_2x_2=0$.
If you like random variables, this is like a real random variable of mean 0 supported on 2 points at most $D$ apart; but for convenience I won't assume $p_1+p_2=1$.
Now define $F_D$ to be the set of all functions which are a sum of $D$-basic functions. I.e., $f\in F_p$ if $f(x)=\sum f_j(x)$ where $f_j$ is $D$-basic for all $j$.
Question 1. Is there a characterisation of $F_D$ that doesn't just restate the definition?
All nonnegative functions $f$ on a finite support $X$ with $\max X-\min X\le D$ and $\sum_{x\in X}xf(x)=0$ are in $F_D$ (easy induction proof) but many other functions are in there too.
Question 2. Given a nonnegative $f$ of finite support, how can we tell if it is in $F_D$? How can we find the smallest $D$ such that $f\in F_D$?
Since any $D$-basic functions in a decomposition of $f$ have a support which is a subset of the support of $f$, Q2 can be solved in polynomial time using linear programming. But that's pretty awful; can it be done in time quadratic or better in the size of the support of $f$?
It should be clear that this setting can be generalised to countable support, and to arbitrary support with some integrability/measurability conditions. Then further to higher dimensions. I'd appreciate any references to this type of question.