程序代写代做 Question:2

Question:2
Suppose you are working for TD’s car insurance program. You are helping the leadership team to set the premium rate for the upcoming year. You are told that there are currently 1 million customers who have their car insurance through TD.
Each customer has a 0.05% of getting into a major accident and a 1% chance of getting into a minor accident. To keep our calculations simple, let’s assume a client can only be involved in a maximum of one accident in a year.
Let X be the amount in dollars that a customer is required to pay to repair his/her vehicle anytime it is involved in a minor accident. And let Y be the amount in dollars that a customer is required to pay anytime it is involved in a major accident.
There is a thousand dollar deductible in every insurance plan, which means TD will not pay anything to the customer if the repair cost is less or equal to $1000. And for any repair cost that is above $1000, the customer pays the first $1000 and TD will pay the rest.
Let X’s probability density function be
f(x)= 1 e≠ 1 x; xØ0
3000 3000 and Y ’s probability density function be
f(y)= 1 e≠ 1 y; yØ0 20000 20000
Let Z be the dollar value that TD needs to pay to each customer during the year.
a)[2 points] Write a function in R that will mimic this whole scenario for one of the customer (i.e. it will simulate if the customer will get into an accident or not, based on the type of accident it will simulate the repair cost and depending on the cost it will calculate the amount TD will have to pay).
b)[0.5 point] Use your function to calculate an estimate of E[Z].
c)[0.5 point] If TD wants to cover the expected TOTAL cost(the total from the claims of all the customers) and a fixed operating cost of 5 million dollars, how much should the monthly premium be for each of their customer?
Expected output:
(a) Code of an R function.
(b) Few lines of R code with one line of R output.
(c) Numeric calculations and/or R code.
© 2020 Shahriar Shams, University of Toronto
Page 3

Question:3
In Lecture-6 (Book chapter 6.2), we learned how to generate random numbers from certain distributions using random numbers from Unif(0,1). You will do two examples here.
(a)[1 point] Suppose X is a continuous random variable with pdf f(x)=4×3 ; 0ÆxÆ1
• Use 100000 random numbers from Unif(0,1) and the distribution function of X to convert each of these uniform random numbers into X.
• Plot a density histogram of the X values that you generated to check if it really looks like the given pdf.
(b)[2 points] Using the same idea as part(a), generate 100000 random numbers from this following pdf
;0Æx<2 ;2ÆxÆ4 ; otherwise Start by deriving the distribution function. Make sure to check the density histogram once you have generated X. Expected output: (a) Distribution function of X, an R code and one plot. (b) Distribution function of X, an R code and one plot. f(x) = 8 _[ 8 0 Y_] 1 x © 2020 Shahriar Shams, University of Toronto Page 4 Question:4 You have “data.csv” file in the assignment page. This dataset gives two related variables collected by Norwegian Public Roads Administration as part of study on air-pollution. No2Con: Concentration of NO2 in the air(measured hourly). NumCar: Number of Cars per hour. Both of the variables are in the log scale. Download and save this file in your laptop/desktop. Now load this data in R studio. There are many options for reading .csv files, but here are few you can use 1) Reading the data interactively data=read.csv(file.choose(),header=TRUE) 2) Using the File > Import Dataset > From Text(base) menu option in R studio to load the file. A
window will popup
• use “Yes” as the option for “Heading”.
• Leave all the other options as the defaults.
Run these following two lines of code this will create two vectors X and Y
a)[2 points] Calculate estimates of these followings only using the “mean()” function of R and some +-*/.
E[X], E[Y], V[X], V[Y], E[XY], cov[X,Y]andfl(X,Y) b)[1 point] Define a variable, Z = eX .
• Do you expect E[Z] to be bigger compared to eE[X]? Justify your answer using any appropriate probability law.
• Check your answer by calculating both of these quantities in R.
Expected output:
a) R codes and single line of outputs for each quantity that you have been asked to calculate. b) Explanation and R code that calculates the two quantities.
X= data$NumCar Y= data$No2Con
© 2020 Shahriar Shams, University of Toronto Page 5

Question:5
(Note: This question relates to Central Limit theorem which we will cover in Lecture 11. This question will make much more sense once we have discussed this in the lecture. For now, just try to follow the steps in each part)
a)[1 point] Write an R function that
• draws two random numbers(n = 2) from a standard normal distribution,
• calculates the average of these n numbers and returns it.
Now replicate this function 100000 times and save the output. Finally, plot a density curve using these saved outputs. What distribution do you think it looks like? Give the name of the distribution and the numeric values of the parameters.
b)[1 point] Write another function that does exactly the same task that you have done in part(a), but this time draw samples from a Uniform(0,1) distribution (instead of standard normal).
Replicate this function 100000 times and plot a density curve using these saved output.
• You should get a dierent plot this time in comparison to the density that you have found in part (a).
• Try increasing the value of n (to 3,4,5,. . . ) and comment at which value of n you start to see the density that you have seen in part(a).
c)[1 point] Replicate part(b), but this time drawing samples from Exponential(⁄ = 1/1000) and comment at which value of n you start to see the density that you have seen in part(a).
Expected output:
a) R codes and one density plot
b) R codes and the density plot corresponding to the n value that you picked as your answer.
c) R codes and the density plot corresponding to the n value that you picked as your answer.
**************************** end of questions *********************************
© 2020 Shahriar Shams, University of Toronto Page 6