1) Prove \[x^2+e^x+2x^4+1\] is convex

A convex function means that two points are selected and a line segment is created, any points on the graph are below the segment line. Requirement for a convex function: there is one global minimum on the graph, its double derivative is greater than zero, and any tangent on the function will be below the line segment of the two points on the function.

When we take the double derivative of the function above…

\[f(x)=x^2+e^x+2x^4+1\] \[f'(x)=2x+e^x+8x^3\] \[f''(x)=2+e^x+24x^2\] \[f''(x)=2+e^x+24x^2>0\]

f’‘(x) will be positive for all real numbers (R). As f’’(x) is greater than zero for all of R, then it is a convex function

#Just graphing the function to show no values below zero
#we can also see that any chord between two points does not cross a point on the graph
x=seq(-pi,pi,0.1)
plot(x,x^2+exp(x)+2*x**4+1)

(Additional resources :Dr.Garg’s convex and concacve functions )

2) Show the mean and variance of the expontial distribution

To find the mean of the exponential distribution, we need to find the expected value for the function. We can use the formula for a continuous random function

\[E(x)=\int_{-\infty}^{\infty}x*f(x) dx\]

Using the formula above, lets solve for E(x) \[E(x)=\int_{0}^{\infty}x\lambda e^{-\lambda x}dx\]

we can solve this integral via substitution by parts \[=\lambda\int_{0}^{\infty}x e^{-\lambda x}dx\] u=x du=1 v=-e^{-lambda x}/lambda dv= e ^{-lambda x} udv=uv-int vdu

\[=\frac{-xe^{{-\lambda x}}}{\lambda}-\int_0^{\infty}\frac{-e^{-\lambda x}}{\lambda}\]

For solving the integral, we can use udu substitution u=-lambdax du/dx=-lambda dx=-1/lambda \[=\frac{1}{\lambda^2}\int e^u du->\frac{1}{\lambda^2}e^{-\lambda x} \] Now, we can solve for [0,inf] \[[\frac{-xe^{{-\lambda x}}}{\lambda}-\frac{1}{\lambda^2}e^{-\lambda x}]_0^{\infty}=\frac{1}{\lambda}\]

To find the variance of the exponential function, we can use the variance formula for continuous random variables

\[Var(x)=E(x^2)-E(x)^2\]

We just need to repeat the steps of the finding the mean for first part of the formula and plug in (I’m going to not annotate again to save me some time :))

\[E(x)=\int_{0}^{\infty}x^2\lambda e^{-\lambda x}dx->\lambda-\int_{0}^{\infty}x^2e^{-\lambda x}dx\] u=x^2 du=2x v=-e^{-lambda x}/lambda dv= e ^{-lambda x} \[=\frac{-x^2e^{{-\lambda x}}}{\lambda}-\int_0^{\infty}\frac{-2xe^{-\lambda x}}{\lambda}dx->\frac{-x^2e^{{-\lambda x}}}{\lambda}-\frac{-2}{\lambda}\int_0^{\infty}xe^{-\lambda x}dx\]

u=x du=1 v=-e^{-lambda x}/lambda dv=-e^{-lambda x} \[=\frac{-xe^{-\lambda x}}{\lambda}-\frac{-1}{\lambda ^2}\int e^{-\lambda x}dx->\frac{-xe^{-\lambda x}}{\lambda}-\frac{e^{-\lambda x}}{\lambda ^2}\] \[[\frac{2xe^{-\lambda x}}{\lambda ^2}+\frac{2e^{-\lambda x}}{\lambda ^3}]_0^{\infty}=\frac{2}{\lambda^2}\]

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

3) Poisson distribution

For this problem, we are first looking at the probability of 4 typos in 1000 words, no typos at all, and its results

#To find the probability of a poisson distribution problem, we will use dpois()
#For Lambda=the mean of a typo (1/250 words). We also are reviewing a 1000 data entries, so we should multiply lambda by 1000
four_w<-dpois(4,lambda=1000*(1/250))
sprintf("The probability of exactly four typos in the entries is %1.2f ",four_w)
## [1] "The probability of exactly four typos in the entries is 0.20 "
#Finding the probability no typos on the data entries
no_typos<-dpois(0,lambda=1000*(1/250))
sprintf("The probability of no typos in the entries is %1.2f ",no_typos)
## [1] "The probability of no typos in the entries is 0.02 "
#its probability distribution graph
hist(rpois(1000,lambda=4),main = "Poisson distribution of data errors",breaks = 10)