I would like to use variational calculus to find the probability density function $p(x)$ that maximizes the tail probability, i.e., I would like to find
\begin{equation} \max_{p(x)} \int_K^\infty p(x) \mathrm{d}x, \end{equation}
where $K>0$. We are also given that the random variable $X$ is nonnegative and has expected value $\mu$. Generalized functions are permitted. I know the answer and a solution method but I wanted to figure out an alternative path that uses variational calculus. Any help would be greatly appreciated.
I formulated the problem as
\begin{align} \max_{p(x)} &\int_K^\infty p(x) \mathrm{d}x \\\\ \mathrm{s.t.} &\int_{-\infty}^\infty xp(x) \mathrm{d}x = \mu\\\\ & \int_{-\infty}^\infty p(x) \mathrm{d}x = 1 \\\\ & p(x) \geq 0. \end{align}
To get rid of the last constraint, I reformulated the problem as
\begin{align} \max_{f(x)} &\int_K^\infty (f(x))^2 \mathrm{u}(x-K)\mathrm{d}x \\\\ \mathrm{s.t.} &\int_{-\infty}^\infty x(f(x))^2 \mathrm{u}(x)\mathrm{d}x = \mu\\\\ & \int_{-\infty}^\infty (f(x))^2 \mathrm{u}(x)\mathrm{d}x = 1, \end{align} where I've made the subtitution $p(x) = (f(x))^2\mathrm{u}(x)$ and $\mathrm{u}(\cdot)$ is the unit step function \begin{equation} \mathrm{u}(x):={\begin{cases}1,&x\geq 0\\\\0,&x< 0\end{cases}}. \end{equation} This substitution for $p(x)$ is meant to accomplish two things: take into account that $p(x)$ is nonnegative for all $x$ (because it is a PDF) and to acknowledge the fact that $X$ is nonnegative.
At this point, I tried using Lagrange multipliers but it didn't lead to anything fruitful. I'm guessing that at some point the fact that the PDF should vanish at $\pm \infty$ might help. I'm also guessing that instead of making this substitution for $p(x)$, I can instead use a Lagrange multiplier that isn't constant. In any case, I'm stuck. Again, any advice would be greatly appreciated!
A probability distribution $p(x)$ is a Cadlag function, don't know for sure if Variational Calculus apply to discontinuous functions: at least for random processes that don't fulfill the requirements to have Fundamental theorem of calculus as valid it were invented the Ito's Calculus (among others), which variational counterpart its Maliavin Calculus, last two quite advanced math, unfortunately I cannot help you (due the links, this were to long for a comment).
But seeing the problem you are working on, maybe an easy alternative could be done if the probability distributions are continuous: see the example of how is proved that the Gaussian Distribution is the Maximum Entropy distribution for a continuous process with finite mean and variance - maybe also just through Laplace multipliers you could also solve your question.
Sorry for not being more useful.