Ex.1

Show x2+exp(x)+2x4+1 is convex.

f(αx+βy)≤αf(x)+βf(y) (αx+βy)2+exp(αx+βy)+2(αx+βy)4+1≤α(x2+exp(x)+2x4+1)+β(y2+exp(y)+2y4+1)

Using α+β=1 we can simplify the inequality and rewrite it as

2αx4+αx2+αexp(x)+2βy4+βy2+βexp(y)+1−((αx+βy)2+exp(αx+βy)+2(αx+βy)4+1)≥0

2αx4+αx2+αexp(x)+2βy4+βy2+βexp(y)−(αx+βy)2−exp(αx−βy)−2(αx+βy)4≥0

The inequality is always true which shows that x2+exp(x)+2x4+1 is convex.

Ex.2

Show that the mean of the exponential distribution

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

is μ=1/λ=1 and its variance is σ2=1/λ2

To find the mean of the exponential distribution solve

\[\mu = E[X] = \int_0^ \infty x \lambda e^{- \lambda x}\]


Solve using integration by parts \[\int u v dx = u \int v dx - \int u' (\int v dx) dx\]

\([-x e^{- \lambda x}]_0^ \infty + \int_0^ \infty e^{- \lambda x} dx=\)

\([-x e^{- \lambda x}]_0^ \infty + [ -\frac{1}{ \lambda } e^{- \lambda x}]_0^ \infty=\)

(0−0)+(0+1/λ) = 1/λ To find the variance of the exponential distribution solve \(\sigma ^{2} = Var[X] = E[ X^{2}] - E[X] ^{2}\)

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

which can be solved by again using integration by parts

\([-x^{2} e^{- \lambda x}]_0^ \infty + \int_0^ \infty 2xe^{- \lambda x} dx=\)

\([-x^{2} e^{- \lambda x}]_0^ \infty +[- \frac{2}{ \lambda } x e^{- \lambda x} dx]_0^ \infty + \frac{2}{ \lambda } \int_0^ \infty e^{- \lambda x} dx\) Again use integration by parts =

\([-x^{2} e^{- \lambda x}]_0^ \infty +[- \frac{2}{ \lambda } x e^{- \lambda x} dx]_0^ \infty + \frac{2}{ \lambda } [- \frac{1}{ \lambda } x e^{- \lambda x} dx]_0^ \infty\)

(2/λ)(1/λ) = 2/λ2

\(E[ X^{2}] - E[X] ^{2} = \frac{2}{\lambda ^{2}} - (\frac{1}{ \lambda }) ^{2} = \frac{2}{\lambda ^{2}} - \frac{1}{\lambda ^{2}} = \frac{1}{ \lambda ^{2}}\)

Ex.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 λ=4 and show their histogram.

lambda <- 4
x1 <- 4
four_typos <- (lambda ^ x1 * exp(-lambda)) / factorial(x1)
four_typos
## [1] 0.1953668

The probability of exactly 4 typos is 19.54%.

lambda <- 4
x2 <- 0
zero_typos <- (lambda ^ x2 * exp(-lambda)) / factorial(x2)
zero_typos
## [1] 0.01831564

The probability of no typos at all is 1.83%.

# Built in R function to check answers
q1 <- dpois(4, lambda = 4)
q1
## [1] 0.1953668
q2 <- dpois(0, lambda = 4)
q2
## [1] 0.01831564
samples <- 1:1000
values <- rpois(1000, lambda = 4)
hist(values)