I am confused about how to make a function for probabilities like these. I was taught the inverse method to be used for this problem as:
X<-NULL n<-number uni<-runif(n,0,1) X[uni<.1]=1 X[uni>.1 & uni<.3]=2 X[uni>.3 & uni<.6]=3 X[uni>.6 & uni<1]=4 length(which(X==1))/n length(which(X==2))/n length(which(X==3))/n length(which(X==4))/n I currently have:
Prob<-function(n){ n<-as.integer(n) uni<-runif(n,0,1) X<-length(n)...?? https://stackoverflow.com/questions/66718096/creating-a-function-in-r-using-the-inverse-transformation-method March 20, 2021 at 11:57AM

没有评论:
发表评论