Maximal entropy distribution in a finite doman with random endpoints I am trying to solve for the distribution of a random variable $x$, which will maximise my entropy in a finite domain, let's say $[0, R]$.
$$
S = -\int_0^Rdxp(x)\ln p(x)
$$
The distribution that maximises this entropy is a uniform distribution of the form, $p(x) = 1/R$.
On the other hand, if I set the endpoint $R$ to be a random variable, given by some distribution (let's consider, $p(R) = R^{-1}\exp(-r/R)$), then how can we calculate the maximal entropy distribution?
Can we use a method similar to Lagrange's multiplier technique?
Edit 1:
As pointed out by Ninad Munshi in the comments, the entropy itself becomes a random variable in this scenario. Therefore, should we look for another rule (instead of the maximum entropy principle), which can be used to calculate the best distribution?
 A: The distribution posed can be considered as conditional on the value of $r$, i.e., we have
$$S(r)=-\int_0^Rdxp(x|r)\log p(x|r).$$
We then obtain $$p(x|r)=\frac{\theta(r-x)}{r},$$ where $\theta(x)$ is the step-function. Then the joint distribution is
$$
p(x,r)=p(x|r)p(r)=\frac{\theta(r-x)}{rR}e^{-\frac{r}{R}}.
$$
Marginalizing in respect to $r$ we obtain the distribution of $x$:
$$
p(x)=\int_0^{+\infty}dr p(x,r)=\frac{1}{R}\int_x^{+\infty}\frac{dr}{r}e^{-\frac{r}{R}}=
\frac{1}{R}\int_{\frac{x}{R}}^{+\infty}dt\frac{e^{-t}}{t}=
\frac{E_1(\frac{x}{R})}{R},
$$
where $E_1(z)$ is an exponential integral.
Remark
If one wished to approach this problem from the point of view of Lagrange multipliers, one could maximize the entropy for the joint distribution function $p(x,r)$ with the constraint that $p(r)$ is given by the form required form:
$$
S = -\int_0^{+\infty}dr\int_0^rdxp(x,r)\log p(x,r) + 
\int_0^{+\infty}dr\lambda(r)\left[\int_0^rdxp(x,r)-p_0(r)\right],\\
p_0(r)=\frac{1}{R}e^{-\frac{r}{R}}
$$
where differentiation in respect to a Lagrange multiplier is replaced by functional variation in respect to $\lambda(r)$.
