Question
Please use R to answer this question and include the code you used with your answers. This question is about the 'log-uniform' prior distribution which
Please use R to answer this question and include the code you used with your answers. This question is about the 'log-uniform' prior distribution which we'll use at times during the course.
A quantity is known to be positive and somewhere between 3 and 55 (inclusive).
(a) In R, make a vector called beta that contains the set of possible values. Go from 3 to 55 in steps of 1. [1 mark]
> B<-seq(from=3 , to=55 , length=53)
(b) Create an R vector to represent a discrete uniform prior distribution, i.e., assigning equal prior probabilities to each possibility. [1 mark]
p<-c(rep(1/53,53))
(c) Find the expected value and variance for . [2 marks]
p<-c(rep(1/53,53))
> Bp<-B*p
> mean<-sum(Bp)
> mean
[1] 29
#variance
> BBp<-B*B*p
sB<-sum(BBp)
> sB
[1] 1075
variance<-sB-mean^2
> variance
[1] 234
(d) According to the uniform prior distribution, calculate P (5 10.5)?
> condition1<-B>=5
> condition2<-B<=10.5
> z<-c(condition1&condition2)
> probability<-length(z[z==TRUE])/length(B)
> probability
[1] 0.1132075
(e) Create an R vector to represent a log-uniform prior distribution, where the probabilities are proportional to 1/. Hint: Construct a vector of un-normalised probabilities first, then normalise it the same way as you would normalise a posterior. [1 mark]
(f) According to the log-uniform prior distribution, what are the values of the same probability as in part (d)? [1 mark]
(g) Find the expected value and variance for where the probabilities are proportional to 1/. [1 mark]
Hello I need help with (e), (f) and (g). Thanks!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started