Download 1. Discrete random variables. Let X be a discrete random variable

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1. Discrete random variables. Let X be a discrete random variable with possible values
1, 2 and 3 which probabilities of these values are: P (X = 1) = 0.5, P (X = 2) = 0.2
and P (X = 3) = 0.3). Answer the following questions:
• What is the value of µX = E(X)?
• Explain in words what µX represents.
2 = V ar(X)?
• What is the value of σX
2 represents.
• Explain in wods what σX
• What is the value of F (2) = P (X ≤ 2)?
• What is the value of P (X > −2)?
Define a new random variable Y = 2X 2 + 3. Answer the following questions:
• What are the possible values of Y and their probabilities?
• What is the value of µY = E(Y )?
• What is the value of σY2 = V ar(Y )?
• What are the values of Cov(X, Y ) and ρXY = corr(X, Y )?
• What does ρXY represent?
• Plot FY for all the possible values of Y .
2. Continuous random variables. Let Z be a continuous random variable with a standard distribution N (0, 1). Answer the following questions:
• What are the possible values of Z?
• What is the value of µZ = E(X)? What is i
• Explain in words what µZ represents.
• What is the value of σZ2 = V ar(X)?
• Explain in wods what σZ2 represents.
• What is the expression of density function?
• What is the expression of the distribution function?
1
• What is the expression of the mean?
• What is the expression of the variance?
Define a new random variable Y = 3Z + 2. Answer the following questions:
• What are the possible values of Y ?
• What is the expression of the density function (fY ) of Y ?
• What is the expression of the distribution function (FY ) of Y ?
• What is the value of µY = E(Y )?
• What is the value of σY2 = V ar(Y )?
• What are the values of Cov(Z, Y ) and ρZY = corr(Z, Y )?
• Plot FY for all the possible values of Y .
3. Random variables and R. Intall R and RStudio in your computer, google it!
• Type in the console in the left down screen help.search(”normal distribution”).
• Type help (rnorm).
• Type ?rnorm
• How is the binomial distribution?
Simulate a sample fo 200 value of a Bernoulli variable with probability of success 0.3
(W ∼ Bernoulli(p = 0.3)).
• What is the value of µW ? How do you estimate it in R?
2 ? How do you estimate it in R?
• What is the value of σW
Simulate 200 values of Z and Y of exercise 2.
• Plot the density and distribution functions of Z and Y.
• Estimate their mean, variance and covariance.
4. Conditional probabilities. We have two discrete variables X and Y . X can take
values 1, 2, 3 corresponding to three hair styles blonde, dark and bold. The variable
Y can take two values 1 and 0 corresponding to female and male. We know that these
variables probability table is:
2
X/Y
Female (1)
Male (0)
Total
Blonde (1)
0.22
0.10
0.32
Dark (2)
0.29
0.18
0.47
Bold (3)
0.01
0.20
0.21
Total
0.52
0.48
1
• What is the conditional probability P (X = 1|Y = 0)?
• What is the P (X = 1)?
• P (Y = 0)?
• What is the joint probability P (X = 1, Y = 0)?
• Are X and Y independent?
5. Linear models, matrix algebra and R.
• Create a script called ”myfirstR.R” with the following commands:
Y=numeric(2)
X=matrix(1, 2,2)
X[1,2]=3
X[2,2]=4
beta= c(2, 3)
Y=X%*%beta
det(X)
Y
solve(X, Y)
solve(X)%*%Y
library(fBasics)
inv(X)%*%Y
• Understand what each command does.
• Now run the following commands:
3
X2= matrix(c(1, 3, 2, 6), nrow=2, byrow=T)
det(X2)
beta2=solve(X2)%*%Y
• Why cannot we find a solution to this problem?
• Click in the menu ”Session/Set Working directory/To Source File Location”.
What happens?
• Put your cursor next to the first line of your code and click on the button ”Run”
on the right side of this screen.
• Click the button ”Source” instead.
6. Create a script (File/New/R script) with the following commands:
X=matrix(1, 1000, 3)
X[,2]=rchisq(1000, df=2)
X[,3]=rnorm(1000, 1, 0.6)
epsilon=rnorm(1000, 0, 0.2)
beta=c(2, -3, 0.4)
Y=X%*%beta+ epsilon
solve(X)%*%Y
solve(X%*%X)%*%(X%*%Y)
solve(X%*%t(X))%*%(t(X)%*%Y)
solve(t(X)%*%X)%*%(t(X)%*%Y)
model.1<-lm(Y~X)
summary(model.1)
• Understand what each command does and why some of them fail.
• Interpret the results in model.1.
7. Maximum likelihood:
Given a sample of n independent identically distributed observations y1 , y2 , . . . , yn ,
normally distributed yi ∼ N (µ, σ 2 ).
• What is the joint density function of this sample?
• What is the likelihood function of this sample?
4
• What is the log-likelihood function of this sample?
• What is the score vector of the log-likelihood function?
• What is the Hessian?
5
Related documents