Question

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 Fair Rolls", 
 xlab="Rolls",
 ylab="Probability",
 xlim=c(0,30), 
 breaks=-1:1000+1,
 prob=TRUE)

Homework Answers

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
(Programmed in R) Will need the code and results. In addition, please report each estimate in...
(Programmed in R) Will need the code and results. In addition, please report each estimate in a sentence that indicates what probabilities these are estimates of. You are not allowed to use any “if” statements or loops in your R code except for the loop to repeat the simulation 1 million times. 1. Estimate by simulation in R using 1 million replications: I roll a fair 6-sided die 10 times. What’s the probability that no two consecutive rolls are the...
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...
Suppose I roll two six-sided dice and offer to pay you $10 times the sum of...
Suppose I roll two six-sided dice and offer to pay you $10 times the sum of the numbers showing. (e.g., if I roll a 4 and a 5, I will pay you $10 * (5+4) = $90). The probability chart for each roll is given: Roll (x) 2 3 4 5 6 7 8 9 10 11 12 Probability (p(x)) 0.027778 0.055556 0.083333 0.111111 0.138889 0.166667 0.138889 0.11111 0.083333 0.055556 0.027778 Now we are going to play the game 100...
One of the most popular games of chance is a dice game known as “craps”, played...
One of the most popular games of chance is a dice game known as “craps”, played in casinos around the world. Here are the rules of the game: A player rolls two six-sided die, which means he can roll a 1, 2, 3, 4, 5 or 6 on either die. After the dice come to rest they are added together and their sum determines the outcome. If the sum is 7 or 11 on the first roll, the player wins....
Conducting a Simulation For example, say we want to simulate the probability of getting “heads” exactly...
Conducting a Simulation For example, say we want to simulate the probability of getting “heads” exactly 4 times in 10 flips of a fair coin. One way to generate a flip of the coin is to create a vector in R with all of the possible outcomes and then randomly select one of those outcomes. The sample function takes a vector of elements (in this case heads or tails) and chooses a random sample of size elements. coin <- c("heads","tails")...
Hi, I need a program in C, where it will prompt a user for a math...
Hi, I need a program in C, where it will prompt a user for a math quiz, either easy or medium. If the user choses difficulty easy, it will prompt the user for how many questions they would like from 1-5. If the user enters medium it will prompt the user on how many questions they would like from 1-10. After those prompts are entered questions will be displayed using rand(), the questions must be multiple choice or division, aswell...
For this assignment, design and implement a class to represent a die (singular of "dice"). A...
For this assignment, design and implement a class to represent a die (singular of "dice"). A normal bag of dice for playing Dungeons and Dragons, for example, contains dice with the following numbers of sides: 4, 6, 8, 10, 12, 20, and 100. In this program, the sides (or faces) of the die are numbered, starting with one. The current face value of the die corresponds to the side that is currently facing upward. By default, the face value is...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
Task #4 Calculating the Mean Now we need to add lines to allow us to read...
Task #4 Calculating the Mean Now we need to add lines to allow us to read from the input file and calculate the mean. Create a FileReader object passing it the filename. Create a BufferedReader object passing it the FileReader object. Write a priming read to read the first line of the file. Write a loop that continues until you are at the end of the file. The body of the loop will: convert the line into a double value...
C++ PROGRAM SPECIFICATION For the assignment, we will use the previous assignment’s program that determines whether...
C++ PROGRAM SPECIFICATION For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements… The program should now determine the number of classes, and should do so by generating a unique, random number. Replace taking user input for the number of rooms with a computer generated number...