Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
The following code computes the exact probability distribution for the sum of two dice:
int SIDES = 6;
double[] dist = new double[2*SIDES+1];
for (int i = 1; i <= SIDES; i++)
for (int j = 1; j <= SIDES; j++)
dist[i+j] += 1.0;
for (int k = 2; k <= 2*SIDES; k++)
dist[k] /= 36.0;
The value dist[i] is the probability that the dice sum to k. Run experiments to validate this calculation simulating N dice throws, keeping track of the frequencies of occurrence of each value when you compute the sum of two random integers between 1
and 6. How large does N have to be before your empirical results match the exact results
to three decimal places?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Suppose that we are given a divisor and a target count, and we need to find the range of numbers from 1 that will have the target count of numbers divisible by the divisor. For example. If the divisor is 3 and the target count is 4, the range is 1 to 12, as in this range there are 4 numbers divisible by 3, viz. 3, 6, 9, and 12. Use a while loop to find the ending number of the range within which we will have the target count of numbers that are divisible by the divisor and print the result. Test the code with divisor = 13 and target count = 5. The printed result should be “Between 1 and 65 there are 5 numbers divisible by 13.” In rstudioarrow_forwardConsider the two following random arrays "a" and "b":| a = np.random.randn(4, 3) # a.shape = (4, 3) b = np.random.randn(3, 2) # b.shape=(3, 2) c = a*b What will be the shape of "c"?arrow_forwardSize of sample space L.A An eleven-sided dice is rolled and a five-sided is tossed. Considering this as a probability experiment, what is the size of the sample space? An Event In the context of the probability experiment just described. Consider the event in which the two numbers on the two dice add to 12. What is the size of this set? 1.B Probability of an event (1/2) What is the probability of the event just described? Write your answer as a fraction of integers. For example, if the answer were 17/20 then enter 17/20 with no spaces or other symbols. You may reduce the fraction by cancelling factors common to the numerator and denominator but you do not need to do this. 1.C Probability of an event (2/2) What is the probability that upper faces on the two dice add to fifteen? Write your answer as a fraction of integers. For example, if the answer were 17/20 then enter 17/20 with no spaces or other symbols. You may reduce the fraction by cancelling factors common to the numerator and…arrow_forward
- Assign is Teenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign is Teenager with false. 439894.2564214.qx3zqy7 1 import java.util.Scanner; □NM nor 2 3 public class TeenagerDetector { 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; kidAge scnr.nextInt(); * Your solution goes here if (isTeenager) { System.out.println("Teen"); } else { System.out.println("Not teen");arrow_forwardThere is more than one way to calculate the value of T. One way that this can be done is by generating random numbers. This works by recognizing that if you take a unit square that you can draw a quarter circle of unit radius inside the square. The area of the quarter circle is exactly π/4 and the area of the square is 1. So if you randomly generate a pair of uniform numbers between 0 and 1 they will be distributed uniformly across the square. If you count the total number of points generated and the number of points (x, y) where x² + y² = ² < 1 then the ratio of those two numbers will tend towards the ratios of the areas of the square and the circle as the number of points generated increases. The ratio of the areas is just π/4 so if you take that ratio and multiply it by 4 you get an estimate for . a) b Write code to estimate π using this method. You can generate random numbers in the range 0arrow_forwardPart 1: Initialize variables for player (“P”), a round counter (“r”), and a trial counter (“t”). Part 2: Initialize matrices for Player 1 Wins (P1Wins), Player 2 Wins (P2Wins) that is the length of the number of “Rounds” I am creating a dice game simulation on matlab and got confused with these few steps. Is it asking to simply assign variables such as P = player, r = round_counter etc. Furthermore, for part two there is 11 rounds total in the game. For the matrices, would it be P1Wins = [1 , 2 , 3 ,4 ... 11]? Thank youarrow_forwardPART B Write the following three methods and include in the Part D code listing: public int GetRandomUniform(int min, int max) This method returns a random number from a uniform distribution between min and max. public double GetRandomNormal(double mean, double stddev) This method returns a random number from a normal distribution with a mean of mean and standard deviation of stddev public int GetBinIndex(double mini, double maxi, int numbins, double valuetobin) This method returns the Bin Index given an input minimum of mini, input maximum of maxi, numbins number of bins, and a value to bin of valuetobin PART C Include the methods created in part B to develop a Visual C# .NET program that will simulate the basic profit calculation, PT = nPv, where n follows a uniform distribution, P, follows a normal distribution, and the user can input the number of bins and number of iterations. The user must also input the min and max for n and the mean and standard deviation for Py. Finally, the…arrow_forwardThere is an upcoming football tournament, and the n participating teams are labelled from 1 to n. Each pair of teams will play against each other exactly once. Thus, a total of matches will be held, and each team will compete in n − 1 of these matches. There are only two possible outcomes of a match: 1. The match ends in a draw, in which case both teams will get 1 point. 2. One team wins the match, in which case the winning team gets 3 points and the losing team gets 0 points. Design an algorithm which runs in O(n2 ) time and provides a list of results in all matches which: (a) ensures that all n teams finish with the same points total, and (b) includes the fewest drawn matches among all lists satisfying (a). Do not write the code, give steps and methods. Explain the steps of algorithm, and the logic behind these steps in plain English.Please give time complexity. list of results mean Any combination of wins, losses and draws. You may wish to view this as a mapping from the set of…arrow_forwardTrue/false: The following program has a race on the value of myid. void *printld(void *vargp) { int myid="((int *)vargp); printf("%d\n", myid); return NULL; } int main() { } pthread_t tid[2]; int i; for (i = 0; i < 2; i++) Pthread_create(&tid[i], NULL, printld, &i); Pthread_join(tid[0], NULL); Pthread_join(tid[1], NULL);arrow_forwardarrow_back_iosarrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education