In: Math
Solve following using Program R studio. Please show code and results. Thank you.
3. Assume that ? is a random variable represents lifetime of a
certain type of battery which is exponentially distributed with
mean 60 hours.
a. Simulate 500 pseudorandom numbers (using set.seed(10)) and
assign them to a vector called expran.
b. Calculate average of simulated data and compare it with
corresponding theoretical value.
c. Calculate probability that lifetime is less than 50 hours using
cumulative probability function.
d. Calculate the total lifetime for these 500 simulated
lifetimes.
e. Calculate 80th percentile using quantile function.
The R-Code is provided as:
a.)
set.seed(10)
expran = rpois(500, lambda = 60)
expran
60 58 49 55 63 50 58 55 68 65 58 67 65 60 52 65 73 60 54 54 59 66
71 59 61 59 60 50 67 61 49 60 60 60 73 53 54 44 52 64 60 67 60 64
70 76 63 66 53 70 66 64 56 53 57 69 65 56 68 60 54 51 62 70 53 56
55 64 58 65 65 63 61 65 77 50 57 58 60 68 64 74 59 55 54 67 63 83
69 63 58 65 60 51 68 56 66 57 68 65 69 67 56 47 50 64 68 53 57 67
55 44 59 69 80 54 65 67 47 71 74 61 68 74 79 59 49 56 61 64 57 42
58 51 47 61 82 54 56 61 53 61 48 65 50 68 55 75 63 59 66 64 55 49
57 76 57 59 56 60 67 54 60 53 70 62 70 63 65 57 51 63 61 74 69 56
87 63 49 56 55 57 51 57 53 60 72 64 70 57 57 60 62 66 53 63 57 72
65 66 63 63 59 60 57 56 68 67 48 49 68 54 71 61 62 76 83 62 62 88
73 66 65 40 57 58 37 78 71 54 56 77 62 60 51 44 50 55 62 70 61 64
53 73 70 67 55 58 69 71 64 55 52 62 56 58 66 59 58 51 59 58 75 71
50 59 79 56 66 58 56 54 56 56 63 64 44 60 66 57 60 62 64 69 62 56
53 72 55 65 44 53 53 68 76 63 69 67 65 75 68 65 49 64 50 66 54 46
59 63 57 59 60 75 59 65 59 57 57 68 74 55 54 42 58 55 60 66 55 60
67 76 55 67 60 52 63 54 57 52 65 58 69 50 71 76 73 58 52 63 69 55
55 58 54 54 70 59 67 60 66 57 64 62 71 61 64 60 67 61 53 53 56 60
49 59 54 54 54 57 65 52 54 55 68 59 48 56 68 59 55 66 50 50 70 77
62 75 50 58 70 66 48 62 68 61 61 60 55 69 60 42 56 58 52 74 64 60
56 66 73 69 60 72 68 49 52 59 67 68 63 62 58 63 49 60 59 58 60 57
76 59 54 53 69 66 75 61 70 62 62 53 50 46 39 51 59 67 58 67 80 54
65 58 61 71 56 57 67 71 68 61 49 65 52 54 57 56 46 55 43 55 64 54
58 62 61 75 50 67 62 75 61 59 60 64 50 50 77 56
b.) The average of simulated data is computed as:
mean(expran)
60.748
Hence, we observe that the average of simulated data is quite close to the mean of the exponentially distributed random variable M which is 60 hours.
c.) The probability that the lifetime is less than 50 hours using cumulative probability function is:
ppois(49,lambda = 60, lower.tail = T)
0.08440668
d.) The total lifetime for these 500 simulated lifetimes is obtained as:
sum(expran)
30374
e.) The 80th percentile using quantile function is obtained as:
quantile(expran, 0.8)
80%
67