I am reading the article of Deriving probability distributions using the Principle of Maximum Entropy
and I am trying to derive some of the equations in it automatically using Mathematica.
1. Derivation of maximum entropy probability distribution with no other constraints (uniform distribution)
First, we solve for the case where the only constraint is that the distribution is a pdf, which we will see is the uniform distribution. To maximize entropy, we want to minimize the following function: $$ J(p)=\int_a^b p(x) \ln p(x) d x-\lambda_0\left(\int_a^b p(x) d x-1\right) $$ . Taking the derivative with respect ot $p(x)$ and setting to zero, $$ \frac{\delta J}{\delta p(x)}=1+\ln p(x)-\lambda_0=0 $$
Can I derive the second equation automatically using Mathematica?
if just $ J(p)=\int_a^b p(x) \ln p(x) dx$, I can do
Needs["VariationalMethods`"]
VariationalD[p[x] Log[p[x]], p[x], x]
the output is 1 + Log[p[x]]
as expected.
But here $ J(p)=\int_a^b p(x) \ln p(x) d x-\lambda_0\left(\int_a^b p(x) d x-1\right) $, how can I do that?
VariationalD[p[x] Log[p[x]] - λ0 ( p[x] - 1), p[x], x]
? What's the issue? $\endgroup$1 - λ0 + Log[p[x]]
which is the expected answer from the OP $\endgroup$