Exercise 1

Show that \(x^{2} + e^{x} + 2x^{4} + 1\) is convex.

A function is considered convex if:
\(f(\alpha x+ \beta y) \le \alpha f(x) + \beta f(y), x,y \in \Omega, \alpha \ge0, \beta \ge0, \alpha + \beta = 1.\)

Applying this to \(f(x) = x^{2} + e^{x} + 2x^{4} + 1\), we get the following equation:

\((\alpha x + \beta y)^{2} + e^{\alpha x + \beta y} + 2(\alpha x + \beta y)^{4} + 1 \le \alpha(x^{2} + e^{x} + 2x^{4} + 1) + \beta(y^{2} + e^{y} + 2y^{4} + 1)\)

\((\alpha ^2 x^2 + 2\alpha\beta xy+ \beta^2y^2) + e^{\alpha x + \beta y} + 2(\alpha x + \beta y)^{4} + 1 \le \alpha x^{2} + \alpha e^{x} + \alpha 2x^{4} + \alpha + \beta y^{2} + \beta e^{y} + \beta2 y^{4} + \beta\)

Since \(\alpha + \beta = 1\) they cancel out and give us:
\((\alpha ^2 x^2 + 2\alpha\beta xy+ \beta^2y^2) + e^{\alpha x + \beta y} + 2(\alpha x + \beta y)^{4} \le \alpha x^{2} + \alpha e^{x} + \alpha 2x^{4} + \beta y^{2} + \beta e^{y} + \beta2 y^{4}\)

We see the follow can be simplified: \(\alpha\beta(x-y)^2 = (\alpha x^2 + \beta^2 - \alpha^2 x^2 - \beta^2y^2) - 2\alpha\beta xy)\)
\(e^{\alpha x + \beta y} + 2(\alpha x + \beta y)^{4} \le \alpha\beta(x-y)^2 + \alpha e^{x} + \alpha 2x^{4} + \beta e^{y} + \beta2 y^{4}\)

\(0 \le \alpha\beta(x-y)^2 + \alpha e^{x} + \alpha 2x^{4} + \beta e^{y} + \beta2 y^{4} - e^{\alpha x + \beta y} - 2(\alpha x + \beta y)^{4}\)

In order to confirm this function is convex, I would need to further simply the function and I couldn’t figure out this problem. Many parts are already okay to call convex such as \(\alpha\beta(x-y)^2\) since no matter what the values are they will always prove to be \(\ge 0\). \(\alpha e^{x} and \beta e^{y}\) are always okay since they follow the rule if exp[f(x)] is convex if f(x) is convex. We know \(\alpha f1 + \beta f2\) is convex if \(f1 and f2\) are convex, which allows us to view each piece of the function separately.

Exercise 2

Show that the mean of the exponential distribution

\[p(x)=\begin{cases} \lambda e^{-\lambda x}, x\ge0(\lambda >0),\\\\0, x<0, \end{cases} \]

is \(\mu = 1/\lambda\) and its variance is \(\sigma^{2} = \frac{1}{\lambda^{2}}\).



To find the mean we know that:
\[\mu = E[X] = \int xp(x)dx\] \[\mu = E[X] = \int_{-\infty}^{0}x*0dx + \int_{0}^{\infty}x\lambda e^{-\lambda x} dx\] \[\mu = 0 + \lambda\int_{0}^{\infty}x e^{-\lambda x} dx\] Using integration by parts and \(u = x, dv = e^{-\lambda x}\) we see:
\[\mu = \lambda(\frac{-xe^{-\lambda x}}{\lambda}|_0^{\infty} - \int_0^{\infty}\frac{-e^{-\lambda x}}{\lambda }dx)\] \[\mu = \lambda(\frac{-xe^{-\lambda x}}{\lambda}|_0^{\infty} + \frac{1}{\lambda} \int_0^{\infty}e^{-\lambda x}dx)\] \[\mu = \lambda( \frac{-xe^{-\lambda x}}{\lambda }|_0^{\infty} + \frac{1}{\lambda} (\frac{e^{-\lambda x}}{-\lambda})|_0^{\infty})\] \[\mu = \lambda(\infty - 0 - \infty + \frac{1}{\lambda^2})\] \[\mu = \lambda( \frac{1}{\lambda^2})\]

\[\mu = \frac{1}{\lambda}\]

To find the variance we know that:
\[\sigma^2 = E[X^2]- E[X]^2\]

We already know that \(E[X] = \frac{1}{\lambda}\) from the previous problem. Let’s solve for E[X^2]:

\(E[X^2] = \int_{0}^{\infty}x^2\lambda e^{-\lambda x} dx\)

Using integration by parts for \(u=x^2\) and \(dv = \lambda e^{-\lambda x}\) we get the following:
\(E[X^2] = ((x^2)(e^{-\lambda x})|_0^{\infty} - \int_0^{\infty}(e^{-\lambda x})(2x)dx)\)
\(E[X^2] = (0 - \int_0^{\infty}(e^{-\lambda x})(2x)dx)\)
\(E[X^2] = -2 \int_0^{\infty}xe^{-\lambda x}dx)\)

Here we use integration by parts with \(u=x\) and \(dv=e^{-\lambda x}\):
\(E[X^2] = -2(\frac{-xe^{-\lambda x}}{\lambda}|_0^{\infty} + \int_0^{\infty}\frac{e^{-\lambda x}}{\lambda}dx)\)
\(E[X^2] = -2(0 - \frac{e^{-\lambda x}}{\lambda^2}|_0^{\infty})\)
\(E[X^2] = (-\frac{e^{-\lambda x}2}{\lambda^2}|_0^{\infty})\)
\(E[X^2] = \frac{2}{\lambda^2})\)

Plugging back in we get:
\[\sigma^2 = E[X^2]- E[X]^2\] \[\sigma^2 = \frac{2}{\lambda^2}- (\frac{1}{\lambda})^2\] \[\sigma^2 = \frac{1}{\lambda^2}\]

Exercise 3

It is estimated that there is a typo in every 250 data entries in a database, assuming the number of typos can obey the Poisson distribution. For a given 1000 data entries, what is the probability of exactly 4 typos? What is the probability of no typo at all? Use R to draw 1000 samples with X = 4 and show their histogram.

## [1] "The probability of exactly 4 typos is:"
## [1] 0.1953668
## [1] "Using only R functions, we see the probability of exactly 4 typos is:"
## [1] 0.1953668
## [1] "The probability of exactly 0 typos is:"
## [1] 0.01831564
## [1] "Using only R functions, we see the probability of exactly 0 typos is:"
## [1] 0.01831564