# Expected value of a generalized exponential distribution

(This is taken from a class.) I was given a generalized exponential distribution: $f(x) = \alpha/\beta\, e^{-x/\beta}+c$. As follows and calculate the expected value of the distribution:

\begin{eqnarray} f(t) &=& \color{red}{\alpha}\frac{_1}{^\beta}e^{-\frac{t}{\beta}}+\color{red}{C}\\ &=& (3.34\times 10^{-1})\cdot(2.172\times 10^{-3})\cdot \,e^{-2.172\times 10^{-3}\,t}\,+\:\text{(negligible)}\\ \mathbb{E}[t]&\approx& 153.83 \text{ seconds} \end{eqnarray}

But what confused me is the way he calculate the expected value. Here's what he do in the python code:

# define fit function
def fitFunc_gen(t, a, b, c):
return a*(b)*numpy.exp(-b*t)+c

# find fit parameters of a,b,c
fitParams_gen, fitCov_gen = curve_fit(fitFunc_gen, division[0:len(division)-1],
count, p0=[0, 3e-4, 0])

#expect value
ev = (1/fitParams_gen[1])*fitParams_gen[0]+fitParams_gen[1]
# ev= 153.8330951411821


As can be seen from the code, the formula he used for expected value is: $E(X) = \alpha\times\beta + 1/\beta$. However I did the calculation myself:

\begin{eqnarray} E(X) &=& \int_{-\infty}^\infty x f(x) dx\\ &&\hspace{2.5cm}\:\downarrow\:c\approx 0\\ E(X) &=& \int_{-\infty}^\infty x \frac{\alpha}{\beta}\,e^{-\frac{x}{\beta}} dx\\ &=&\frac{\alpha}{\beta}\int_{0}^\infty x \,e^{-\frac{x}{\beta}} dx\\ &=&-\alpha\int_{0}^\infty x\,(-\frac{1}{\beta}) \,e^{-\frac{x}{\beta}} dx\\ &=&-\alpha\int_{0}^\infty x\, de^{-\frac{x}{\beta}}\\ &=&-\alpha \left( xe^{-\frac{x}{\beta}}|_{0}^\infty - \int_{0}^\infty e^{-\frac{x}{\beta}}dx \right)\\ &=&-\alpha\left(0+ \beta\int_{0}^\infty (-\frac{1}{\beta})e^{-\frac{x}{\beta}}dx\right)\\ &=&-\alpha\beta\int_{0}^\infty (-\frac{1}{\beta})e^{-\frac{x}{\beta}}dx\\ &=&-\alpha\beta e^{-\frac{x}{\beta}}|_{0}^\infty=\alpha\beta \end{eqnarray}

I think it should be $E(X)=\alpha\times\beta$.

Can anyone correct me?

The whole thing is problematic, because you don't specify the support of the claimed probability density. If $X$ is a random variable with density $$f_X(x) = \frac{\alpha}{\beta}e^{-x/\beta} + c,$$ then there is necessarily some relationship between the parameters $\alpha, \beta, c$ and the subset $x \in \Omega \subseteq \mathbb R$ for which $f(x) > 0$ and $$\int_{x \in \Omega} f_X(x) \, dx = 0.$$ Note, for instance, that if $c \ne 0$ and $\Omega$ comprises a single continuous interval, the support is necessarily bounded below and above. If we require $\Omega = (0, \infty)$, then this forces $c = 0$. If $c = 0$, then again on this same interval, we would obtain $$\int_{x=0}^\infty f_X(x) \, dx = \alpha = 1,$$ thus $X$ is your usual exponential distribution with mean $\beta$.
• $f(x) = \alpha/\beta\, e^{-x/\beta}+c$ is the density. It's a generalized exponential distribution. curve_fit() is basic a parameter estimation. Because the result of c=3.18496892e-06 is nearly 0, so to find E(x), it's set to 0. – milowang Jul 29 '16 at 6:51
• The PDF is specified in terms of $\alpha$, $\beta$, c, and x. $f(x) = \alpha/\beta\, e^{-x/\beta}+c (x>0)$. The density f(x) is 0 for x less than or equal to 0. – milowang Jul 29 '16 at 7:50
• I think there's some "goes without saying" thing that the script didn't say. But the script did calculate the expected value as: $\alpha*\beta+1/\beta$ in here – milowang Jul 29 '16 at 7:56
• @milowang As I have explained, if the support is $X \in (0,\infty)$, then the only value of $c$ for which the function $f$ is a PDF is $c = 0$; and if $c = 0$, then you are also forced to have $\alpha = 1$. If you obtain some other fit such as what you describe, then the following two statements cannot simultaneously hold: (a) the support is $x \in (0,\infty)$; (b) $f_X(x)$ is a PDF. – heropup Jul 29 '16 at 8:00