Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

1. Write an R function that does the following: · Simulate rolling an arbitrary number of dice (call this number m ). · Take the maximum of the dice minus the minimum of the dice. For example, if m =...

1 answer below »

1. Write an R function that does the following:

· Simulate rolling an arbitrary number of dice (call this number m).

· Take the maximum of the dice minus the minimum of the dice. For example, if m = 5 and the outcomes are 4, 3, 6, 4, 2, the value we’re looking for is 6 – 2 = 4.

· Repeat this process n times, and return a vector of max-min differences

Your function should have as calling arguments m and n (you may assign default values to them if you wish). Include a comment block that explains what the function does.

Use your function to simulate max-min differences for the values m = 4 and n = 10000. From the results produce an estimated probability mass function for this random variable (round to four decimal places).

Some rules:

· Copy your function and R command output into your homework paper;

· Use Courier New font for R stuff. It is a typewriter font that aligns properly;Include only what is needed to solve the problem: no false starts or core dumps. Don’t print out reams of numbers;

· Make sure that everything you do is clear in what you submit. Indicate your final answer so that it is easy to see.

Answered Same Day Oct 15, 2021

Solution

Sudipta answered on Oct 15 2021
147 Votes
##function for taking random value for a dice and find the difference of max and min
new.function<- function(n, m) {
l<-c() ##creating a list to hold all the min,max difference values
##Start of loop
i <- 1
while(i<=n) {
a<-c(1,2,3,4,5,6) ##get random values from a dice
ans=sample(a,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here