(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$.

The takeaway here is that the specification of any probability distribution is incomplete without explicitly stating its support. You can write any density or mass function you like, but if you do not state the support, your distribution is meaningless.

  • $\begingroup$ $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. $\endgroup$ – milowang Jul 29 '16 at 6:51
  • $\begingroup$ @milowang You don't seem to have understood my response. Merely fitting a curve to a set of data does not mean that the curve you have fit is a probability distribution. And if you don't have a proper probability density, attempting to calculate an expectation is meaningless. Your comment is indicative of an insufficient knowledge of basic probability theory; additionally, your failure to specify a support for the random variable you are modeling means your question cannot be answered. $\endgroup$ – heropup Jul 29 '16 at 7:23
  • $\begingroup$ 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. $\endgroup$ – milowang Jul 29 '16 at 7:50
  • $\begingroup$ 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 $\endgroup$ – milowang Jul 29 '16 at 7:56
  • $\begingroup$ @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. $\endgroup$ – heropup Jul 29 '16 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.