# Difficulty finding Expectation of a special function

I have a special function given as:

$${\rm f}\left(r\right) ={1 \over \beta\lambda}\,2^{r/\beta} \exp\left({\left[2^{r/\beta} - 1\right]K \over \lambda}\right)$$

I should find the Expectation of the random variable $r$. Mathematica was not able to solve the associated Integral function. So it returns:

$$\int_0^{\infty}\left\{{1 \over \beta\lambda}\,2^{r/\beta} \exp\left({\left[2^{r/\beta} - 1\right]K \over \lambda}\right)\right\}\ r\,{\rm d}r$$

Does anyone recognize how I can reduce this function so I can solve it further?

==== Edit =====

This is the code I tried:

Integrate[ r*fr, {r, 0, \Infinity}, Assumptions->{K>=1, \lambda >=0, \beta >=0}]

• Please post the code you've already tried. – Dr. belisarius Mar 31 '14 at 6:51
• It looks like unless K/lambda <0 your integral is not convergent. Also, it doesn't look like f[r] it's normalized. – b.gates.you.know.what Mar 31 '14 at 10:04
• Yes right. That's what @ubpdqn showed - $Re[\frac{a3}{a2}]<0$, that is $Re[\frac{K}{λ}]<0$. Unfortunately, I think I have a bigger problem, because both $K$ and $λ$ are positive in my model. $f(r)$ is actually correct. Although I removed a product term $K Log$ from $f(r)$ which on testing does not seem to have any major effect. – Afloz Mar 31 '14 at 10:30

The integral is conditionally convergent. You can progress using substitution: $u=2^{\frac{r}{b}}\iff r= b\log_2 u$ Hence,$\frac{dr}{du}=\frac{b}{u\ln 2}$

You can do these substitutions in Mathematica:

f[r_, b_, la_, k_] := 2^(r/b) Exp[k (2^(r/b) - 1)/la]/(b la)
exp = f[x, a1, a2, a3] /. {2^(x/a1) -> u};
ex = D[a1 Log[2, u], u];
ans = Integrate[a1 Log[2, u] exp ex, {u, 1, Infinity}]


The symbolic integral is thence:

ConditionalExpression[-((a1 E^(-(a3/a2)) Gamma[0, -(a3/a2)])/(
a3 Log^2)), Re[a3/a2] < 0]


Now you can compare numerically:

N@Integrate[r f[r, 1, -1, 1], {r, 0, Infinity}]


yields

-1.24122

and using the symbolic integral:

N[ans /. {a1 -> 1, a2 -> -1, a3 -> 1}]


yields: -1.24122

A small sample:

Grid[Table[{1, j, 1, N@ans /. {a1 -> 1, a2 -> j, a3 -> 1},
Integrate[r f[r, 1, j, 1], {r, 0, Infinity}]}, {j,
Range[-1, -0.1, 0.1]}],
Dividers -> {{False, False, False, True, {False}}, None}] I arbitrarily chose some parameters to illustrate. Further insights regarding convergence can be obtained:

Manipulate[
Plot[{r f[r, 1, j, 1], r f[r, 1, 1, j]}, {r, 0, 10},
PlotRange -> {-1, 10},
Epilog -> Text[Style[j, 20, Red], {6, 5}]], {j, -1, 1, 0.15}] Obviously the parameter constraints (regions of interest) are up to users intention.

• Great! Interesting work. It appears to me that $\lambda$ implies $a2$ which appears to be $< 0$. This seems to contradict our original assumption that $\lambda >= 0$. Am I right? – Afloz Mar 31 '14 at 9:17
• @Methyl see update – ubpdqn Mar 31 '14 at 9:25
• You're quite correct. The solution here is conditioned on $Re[a3/a2] < 0$, that is $Re[\frac{K}{\lambda}] < 0$. Unfortunately, I think I have a bigger problem, both $K$ and $\lambda$ are positive in my model. – Afloz Mar 31 '14 at 9:56
• Let me be the first to give well-deserved +1, a typically neat and clean answer by you. – ciao Mar 31 '14 at 10:07