Question

In: Statistics and Probability

Rstudio Coding Homework (submmite the pdf file to Canvas) Let X be a Possion(λ) random variable....

Rstudio Coding Homework (submmite the pdf file to Canvas)
Let X be a Possion(λ) random variable. We have seen in class that
E(X) = Var(X) = λ.
Suppose that we do not know the true value of λ and want to estimate it from observed data {x1, x2, . . . , xn}.
There are two possible ways to do estimate λ:
• use the sample mean x¯ =
1
n
Pn
i=1 xi
• use the sample variance S
2 =
1
n−1
Pn
i=1(xi − x¯)
2
Please note that in sample variance, the denominator is n − 1 instead of n.
In this assignment, you will compare the two estimators. In the following questions, we assume that
λ = 10.
1. Generate n = 10 independent Poisson(λ) random variables, calculate the sample mean (you can use
rpois(n = ,lambda = ) function in R, where n is the total number of random varables generated and
lambda is the parameter λ). Do the above 1000 times, then you have 1000 observations of the sample
mean (each of them is calculated from n = 10 independent Poisson (λ) random variables.) Generate
the boxplot and histogram of the 1000 observation of sample means.
2. For n = 10, repeat Part 1 with the sample variance.
3. Compare the boxplot and histogram you obtained from Part 1 and 2. Comment on the difference
between them. (Hint: measure of dispersion)

---
title: "MATH 2411 Homework 2"
author: "yu wai man 20600375"
date: "2020/3/26"
output: pdf_document
#output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Coding Howework (submmite the pdf file to Canvas)
Let $X$ be a Possion$(\lambda)$ random variable. We have seen in class that $$\mathbb E(X) = \mathrm{Var}(X) = \lambda.$$ Suppose that we do not know the true value of $\lambda$ and want to estimate it from observed data $\{x_1,x_2, \dots, x_n\}$. There are two possible ways to do estimate $\lambda$:
\begin{itemize}
\item use the sample mean $\bar{x} = \frac{1}{n}\sum_{i = 1}^{n} x_i$
\item use the sample variance $S^2 = \frac{1}{n-1} \sum_{i = 1}^{n} (x_i - \bar{x})^2$
\end{itemize}
**Please note that in sample variance, the denominator is $n-1$ instead of $n$.**

In this assignment, you will compare the two estimators. **In the following questions, we assume that $\lambda = 10$.**

1. Generate $n = 10$ independent Poisson$(\lambda)$ random variables, calculate the sample mean (you can use \verb+rpois(n = ,lambda = )+ function in \verb+R+, where \verb+n+ is the total number of random varables generated and \verb+\lambda+ is the parameter $\lambda$). Do the above $1000$ times, then you have $1000$ observations of the _sample mean_ (each of them is calculated from $n=10$ independent Poisson $(\lambda)$ random variables.) **Generate the boxplot and histogram of the $1000$ observation of sample means.**

```{r sample mean}
# input your r code here

```

2. For $n = 10$, **repeat Part 1 with the _sample variance_.**

```{r sample variance}
# input your r code here

```

3. Compare the boxplot and histogram you obtained from Part 1 and 2. **Comment on the difference between them.** (Hint: measure of dispersion)

```{r boxplot and histogram}
# input your r code here

```

**Write down your comments here**


Solutions

Expert Solution

samp_mean = c() 
samp_var = c() 
x= c() 
for(i in 1:1000){
x = rpois(n = 10 , lambda = 10) 
samp_mean[i] = mean(x) 
samp_var[i] = var(x) 
} 
boxplot(samp_mean) 
hist(samp_mean) 
boxplot(samp_var) 
hist(samp_var) 

Both the plots sample mean and sample variance have measure of centre around 10 which is our parameter lambda =10.

but if we observe variablity in data which is measure of spread,we will conclude that distribution of sample variance have more of extreme observation than distribution of sample mean.

also distribution of sampe mean is quite symmetric .ie normal while distribution of sample variance is right skewed.

plz like)

7 8 9 10 11 12 13 sample mean

Histogram of samp_mean 200 150 Frequency 100 50 0 samp mean

0 5 10 15 20 25 30 35 sample variance

Histogram of samp_var 400 300 Frequency 200 100 0 T T 1 5 10 15 20 25 30 35 samp_var


Related Solutions

Let X be a random variable. Suppose X ∼ Exp(0.5). The area under the pdf of...
Let X be a random variable. Suppose X ∼ Exp(0.5). The area under the pdf of the Exp(0.5) distribution above the interval [0, 2] is 0.6321. What is the value of the cumulative distribution function FX of X at x = 2?
Let X be a exponential random variable with pdf f(x) = λe−λx for x > 0,...
Let X be a exponential random variable with pdf f(x) = λe−λx for x > 0, and cumulative distribution function F(x). (a) Show that F(x) = 1−e −λx for x > 0, and show that this function satisfies the requirements of a cdf (state what these are, and show that they are met). [4 marks] (b) Draw f(x) and F(x) in separate graphs. Define, and identify F(x) in the graph of f(x), and vice versa. [Hint: write the mathematical relationships,...
Let X be a uniform random variable with pdf f(x) = λe−λx for x > 0,...
Let X be a uniform random variable with pdf f(x) = λe−λx for x > 0, and cumulative distribution function F(x). (a) Show that F(x) = 1−e −λx for x > 0, and show that this function satisfies the requirements of a cdf (state what these are, and show that they are met). [4 marks] (b) Draw f(x) and F(x) in separate graphs. Define, and identify F(x) in the graph of f(x), and vice versa. [Hint: write the mathematical relationships,...
Let X be a continuous random variable with pdf: f(x) = ax^2 − 2ax, 0 ≤...
Let X be a continuous random variable with pdf: f(x) = ax^2 − 2ax, 0 ≤ x ≤ 2 (a) What should a be in order for this to be a legitimate p.d.f? (b) What is the distribution function (c.d.f.) for X? (c) What is Pr(0 ≤ X < 1)? Pr(X > 0.5)? Pr(X > 3)? (d) What is the 90th percentile value of this distribution? (Note: If you do this problem correctly, you will end up with a cubic...
2. Let X be a continuous random variable with PDF ?fx(x)= cx(1 − x), 0 <...
2. Let X be a continuous random variable with PDF ?fx(x)= cx(1 − x), 0 < x < 1, 0 elsewhere. (a) Find the value of c such that fX(x) is indeed a PDF. (b) Find P(−0.5 < X < 0.3). (c) Find the median of X.
Let X be an exponential random variable with parameter λ, which means that fX(x) = λe^(−λx)...
Let X be an exponential random variable with parameter λ, which means that fX(x) = λe^(−λx) * u(x). (a) For x > 0, find P(X ≤ x). (b) For x2 > x1 > 0, find P(x1 ≤ X ≤ x2). (c) For x > 0, find P(X ≥ x). (d) Segment the positive real line into three equally likely disjoint intervals.
Let X1,...,Xn be exponentially distributed independent random variables with parameter λ. (a) Find the pdf of...
Let X1,...,Xn be exponentially distributed independent random variables with parameter λ. (a) Find the pdf of Yn= max{X1,...,Xn}. (b) Find E[Yn]. (c) Find the median of Yn. (d) What is the mean for n= 1, n= 2, n= 3? What happens as n→∞? Explain why.
Let y1, y2, .....y10 be a random sample from an exponential pdf with unknown parameter λ....
Let y1, y2, .....y10 be a random sample from an exponential pdf with unknown parameter λ. Find the form of the GLRT for H0: λ=λ0 versus H1:λ ≠ λ0. What integral would have to be evaluated to determine the critical value if α were equal to 0.05?
Let X and Y have joint PDF f(x) = c(e^-(x/λ + y/μ)) 0 < x <...
Let X and Y have joint PDF f(x) = c(e^-(x/λ + y/μ)) 0 < x < infinity and 0 < y < infinity with parameters λ > 0 and μ > 0 a) Find c such that this is a PDF. b) Show that X and Y are Independent c) What is P(1 < X < 2, 0 < Y < 5) ? Leave in exponential form d) Find the marginal distribution of Y, f(y) e) Find E(Y)
Let T be a Kumaraswamy random variable, and X be a Weibull random variable, the T-X...
Let T be a Kumaraswamy random variable, and X be a Weibull random variable, the T-X family will be called the Kumaraswamy-Weibull distribution. Using W[F(x)]=F(x). Obtain (a) both the cdf and pdf of the Kumaraswamy-Weibull distribution. (b) both the hazard and reverse hazard function Kumaraswamy-Weibull distribution. (c) the quantile function Kumaraswamy-Weibull distribution.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT