Ex. 1 - Show that \(x^2 + e^x + 2x^4 + 1\) is convex.

Solution:

A function \(f(x)\) defined on a convex set \(\Omega\) is called convex if \(f(\alpha f(x) + \beta f(y))\), x \(\in \Omega, y \in \Omega\),$ where \(\alpha >= 0, \beta >= 0\), \(\alpha + \beta\) = 1.

Applying this to problem in question, we get:

\((\alpha x + \beta y)^2\) + \(e^\alpha x + \beta y\) + \(2(\alpha x + \beta y)^4 + 1\) <= \(\alpha(x^2 + e^\alpha x + 2x^4 + 1) + \beta(y^2 + e^\alpha y + 2y^4 + 1)\)

Since \(\alpha + \beta\) = 1, we get:

\((\alpha^2x^2 + 2\alpha\beta xy + \beta^2y^2) + e^(\alpha x + \beta y) + 2(\alpha x + \beta y)^4 + 1 <= \alpha x^2 + \alpha e^x + \alpha2 x^4 + \alpha + \beta y^2 + \beta y^4 + \beta e^y + \beta2 y^4\)

Simplifying per below equation, we get:

\(\alpha\beta (x - y)^2 = (\alpha x^2 + \alpha e^x + \alpha2 x^4 + \beta y^2 + \beta e^ y + \beta2 y^4)\)

\(e^(\alpha x + \beta y) + 2(\alpha x + \beta y)^4 <= \alpha\beta(x - y)^2 + \alpha e^x + \alpha2 x^4 + \beta e^ y + \beta2 y^4)\)

Ex. 2 - Show that the mean of the exponential distribution

\(p(x)\) = {\(\lambda e^-\lambda x\), \(x >= 0(\lambda > 0),\) 0, x < 0

is \(\mu = 1/\lambda e\) and its variance is \(\rho = 1/\lambda^2.\)

Solution:

To find the mean we know that:

\(\mu = E[X] = \int xp(x)dx\)

This can be written as \(\mu\) = \(E[X]\) = \(\left(\int_{-infty}^{0} x\; * 0dx\right)\) + \(\left(\int_{0}^{+infty} x\;\lambda e^-\lambda x dx\right)\)

\(\mu = 0 + \lambda \int_{0}^{\infty} xe ^-\lambda x dx\)

Using integration by parts and u = x, dv = \(e^-\lambda x\) we see:

\(\mu\) = \(\lambda\) $(-x e^- \(\lambda\) x/  \(\lambda\) |_{0}^{+inft})$ - \((\left[\int_{0}^{infty})\) -\((e^-\\)$ x/ \(\lambda\) dx)$

\(\mu\) = \(\lambda\) $(-x e^- \(\lambda\) x/  \(\lambda\) |_{0}^{+inft})$ + $(1/$ \(\lambda\) - E[X]^2$

Since we have already derived the value for E[X], we will solve for \(E[X]^2 = \left[\int_{0}^{\infty} x^2\lambdae-\lambdax dx\)

Using integration by parts for \(u = x^2 and v = \lambda e^-(\lambda x)\) we get the following result:

\(E[X^2]\) = \(((x^2)(e^-\lambda x)right|_{0}^{\+inft})\) - $({0}^{} (e^-x){0}^{}) - \((\left(\int_{0}^{\infty}(e^-\lambda x))\) \((right|_{0}2x dx)\)

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

\(E[X^2]\) = \(-2\int_{0}^{\infty}xe^-\lambda xdx\)

Using integration by parts and plugging back we get:

\(\rho^2\) = \(E[X^2] - E[X]^2\)

\(2/\lambda ^2\) - \((1/\lambda)^2\)

\(\rho^2\) = \(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 \(\lambda = 4\) and show their histogram.

Solution:

typor = 1/250
entries = 1000
lambda = entries * typor
x = 4
p_typo = (lambda^x)*(exp(-lambda))/factorial(x)

print("The probability of exactly 4 typos is:") 
## [1] "The probability of exactly 4 typos is:"
p_typo
## [1] 0.1953668
typor = 1/250
entries = 1000
lambda = entries * typor
x = 0
p_typo = (lambda^x)*(exp(-lambda))/factorial(x)

print("The probability of exactly 0 typos is:") 
## [1] "The probability of exactly 0 typos is:"
p_typo
## [1] 0.01831564
events = 1:1000
lambda = 1/250 * 1000
poisson <- rpois(1000, lambda)
df <- data.frame(events, poisson)

hist(df$poisson, main = "1000 samples of typing with lambda = 4")