Question

you will simulate rolling ?n dies and recording their sum. For example, if n=2 and the first die shows up as a 3, and the second die shows up as a 1, the sum (and the value we record) would be 4.

TO DO: Complete the two function stubs below and then demonstrate by providing code which would print out the probability distribution for rolling 2 dice 100,000 times.

seed(0)

def **roll_and_add_dice**(num_dice, num_trials =
10**6):

pass # Your code here

show_distribution(roll_and_add_dice(2),title='Probability Distribution for Sum of Two Dice')

Answer #1

PYTHON CODE:

import matplotlib.pyplot as plt import random def roll_and_add_dice(num_dice, num_trials = 10**6): dict={} for i in range(num_dice,6*num_dice+1): dict[i]=0 for i in range(0,num_trials): sum=0 for j in range(0,num_dice): sum+=random.randint(1,6) dict[sum]+=1 return dict def show_distribution(vectors,title): x=list(vectors.keys()) y=list(vectors.values()) plt.plot(x,y) plt.title(title) plt.show() show_distribution(roll_and_add_dice(2),title='Probability Distribution for Sum of Two Dice')

Output plot:

• Compute the sampling distribution when you add the
outcome of rolling two dice.
o What is the probability that the sum will be higher than or equal
to 9?
o What is the probability that the sum will be between 4 and
6?
o What is the probability that the sum will be higher than 9 given
that one die is a 6?
• A friend of yours rolls two dice and claims that the addition of
those two...

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...

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")...

Assignment 2
1. Assume that you have two biased coins and one fair coin. One
of the biased coins are two tailed and the second biased one comes
tails 25 percent of the time. A coin is selected randomly and
flipped. What is the probability that the flipped coin will come up
tail?
2. One white ball, one black ball, and two yellow balls are
placed in a bucket. Two balls are drawn simultaneously from the
bucket. You are given...

Please read the article and answear about
questions.
Determining the Value of the Business
After you have completed a thorough and exacting investigation,
you need to analyze all the infor- mation you have gathered. This
is the time to consult with your business, financial, and legal
advis- ers to arrive at an estimate of the value of the business.
Outside advisers are impartial and are more likely to see the bad
things about the business than are you. You should...

Sign In
INNOVATION
Deep Change: How Operational Innovation Can Transform Your
Company
by
Michael Hammer
From the April 2004 Issue
Save
Share
8.95
In 1991, Progressive Insurance, an automobile insurer based in
Mayfield Village, Ohio, had approximately $1.3 billion in sales. By
2002, that figure had grown to $9.5 billion. What fashionable
strategies did Progressive employ to achieve sevenfold growth in
just over a decade? Was it positioned in a high-growth industry?
Hardly. Auto insurance is a mature, 100-year-old industry...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 54 seconds ago

asked 22 minutes ago

asked 25 minutes ago

asked 27 minutes ago

asked 31 minutes ago

asked 35 minutes ago

asked 46 minutes ago

asked 46 minutes ago

asked 55 minutes ago

asked 55 minutes ago

asked 55 minutes ago

asked 1 hour ago