Question

in R language (d) Write a computer program to simulate a fair dice. Generate output. Use...

in R language

(d) Write a computer program to simulate a fair dice. Generate output. Use the output to make a plot.

Homework Answers

Answer #1

Solution :

We know that outcomes of fair dice are equally likely.

Let X be sample space.

X= (1:6)

Hence we use simple random sampling from X to simulate a fair dice.

R code :

X= c(1:6)

#take random sample of size 100 from X.

die= sample(X, size = 100, replace = TRUE)

die

# We plot Histogram using output

hist(die)

Output :

[1] 6 2 4 3 4 1 5 3 4 2 6 5 5 5 5 3 6 2 5 6 3 6 6 5 2 3 2 2 3 2 5 4 2 6 5 4 2

[38] 6 3 2 1 1 3 1 1 2 3 5 2 4 3 6 2 1 2 6 5 5 3 4 3 5 4 6 2 5 4 4 1 6 5 5 5 4

[75] 3 3 4 3 4 1 3 3 6 5 6 2 6 5 4 1 1 1 3 4 1 2 4 1 2 5

Plot :

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Language: Python Write a program to simulate an experiment of tossing a fair coin 16 times...
Language: Python Write a program to simulate an experiment of tossing a fair coin 16 times and counting the number of heads. Repeat this experiment 10**5 times to obtain the number of heads for every 16 tosses; save the number of heads in a vector of size 10**5 (call it headCounts). You should be able to do this in 1-3 lines of numpy code. (Use np.random.uniform1 to generate a 2d array of 10**5 x 16 random numbers between 0 and...
Write an R script to simulate tossing a coin. Plot the evolution of the relative frequency...
Write an R script to simulate tossing a coin. Plot the evolution of the relative frequency of heads in a sequence of 100 coin tosses? please use R script
I need this coded in R: I have a program that simulates a fair dice. The...
I need this coded in R: I have a program that simulates a fair dice. The program rolls a fair coin 100 times and counts the number of 1's. The simulation is repeated 10^5 times and stored the outcomes in x and a histogram is plotted. I need to now draw a bell curve showing normal/gaussian distribution over the histogram. Code I have: dice <- function(n) { sample(c(1:6),n,replace = TRUE) } x<-dice(100) x<-numeric(10^5) for(n in 1:10^5){ x[n]<-sum(dice(100)==1) } hist(x, main="100...
Use MARS to write and simulate a MIPS assembly language program to swap two of the...
Use MARS to write and simulate a MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. Download the template file “P4_template.asm” provided on Blackboard. Add your code to this file. Do not modify any of the code provided in the file. The main function should: • Pass the starting address of the array in $a0....
Use a computer to calculate the probability that the sum of outcomes of 5 fair dice...
Use a computer to calculate the probability that the sum of outcomes of 5 fair dice rolls is equal to 21. You may do it in a pencil and paper way. You may not need to provide the source code.
write an 8086 ALP to generate an output triangle signal. In addition, the program stops with...
write an 8086 ALP to generate an output triangle signal. In addition, the program stops with one key press
Dice Rolling) Write an application to simulate the rolling of two dice. The application should use...
Dice Rolling) Write an application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the...
For each of the following, write the requested program or subroutine in pseudocode (as described in...
For each of the following, write the requested program or subroutine in pseudocode (as described in Appendix A) or in a programming language that you know. Test your code either with a paper-and-pencil trace or with a computer run. 1. Write a program that will print a truth table for (p ∨ q) ⇒ r. (Use JAVA language)
Write an assembly language program that prints your full name on the screen. Use .ASII pseudo-op...
Write an assembly language program that prints your full name on the screen. Use .ASII pseudo-op to store the characters at the top of your program Use BR to branch around the characters and use STRO to output your name. Comment each line except STOP and .END. Cut and paste the Assembler Listing into your document Paste a screen shot of the Output area of the Pep8 program Please use the name "Levin Fi" Assembler Listing Screen Shot of the...
We know that in throwing two fair dice independently, the sum of the two outcomes will...
We know that in throwing two fair dice independently, the sum of the two outcomes will be 2, 3, …., 12 with respective probabilities I/36, 1/18, 1/12, 1/9, 5/36, 1/6, 5/36, 1/9, 1/12, 1/18, and 1/36. Simulate 1000 independent throws of a pair of independent fair dice, and compare the observed proportion of 2s, ….., 12s with the known probabilities, using an appropriate test from Law Chapter 6. Use a random number function in Excel to generate the 1000 throws....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT