Question

Use simulations to analyze the behavior of hashing with chaining using the balls-and-bins simulations. Assume being...

Use simulations to analyze the behavior of hashing with chaining using the
balls-and-bins simulations. Assume being given n balls and m bins, and you are throwing n balls uniformly randomly
into m bins. You need to answer the following questions for various combinations of values of n and m:

After throwing n balls into m bins:

1) How many (what fraction of m) of bins were empty? (MIN,MAX and AVERAGE --- explanation below)
2) How many bins (what percentage of m) had more than average (n/m) number of balls, how many had more than twice the average (2n/m) number of balls?
3) How full was the fullest bin? (What percentage of n balls did the fullest bin contain).

You need to answer and plot the answers for each one of these questions for the following values of n and m:
n=16, m=16
n=128, m=128
n=1024, m=1024
n=2^14, m=2^14

n=32, m=8
n=1024, m=128
n=2^14, m=2^10

In order to get a fairly reliable statistic, each one of these experiments should be run 50 times. So the answers you are reporting
need to be the average of those 50 runs. For example, say you are running an experiment for n=16,m=16.

To answer Question 1, you will run the experiment 50 times, and for each time, you will record the number of empty bins. The number
you report will be the minimum number of empty bins that occurred, the maximum number of empty bins that occurred, and the average over the 50 values.

To answer Question 2, you will record the average number (of 50 runs) of the bins that had more than average, and also for more than twice the average number of balls.

To answer Question 3, you will record the average number (over 50 times) of how full was the fullest bin.

PLEASE NOTE:
The solution needs to be in plain text (do it in a MS Word or some other editor and paste the answer))You need to submit three things
- submit the code
- submit the data you obtained from the experiments
- submit your report that contains the results (numbers and plots) as well as YOUR ANALYSIS of the results you got.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You want to use what are called indicator variables. To see how this works, let's take your first problem. Let YY be the number of bins that are empty. You want E[Y]E[Y]. Now define the indicator variables XiXi so that XiXi is 11 if bin ii is empty and 00 otherwise. Then we have

Y=X1+X2+⋯+Xn.Y=X1+X2+⋯+Xn.

By linearity of expectation,

E[Y]=E[X1]+E[X2]+⋯+E[Xn].E[Y]=E[X1]+E[X2]+⋯+E[Xn].

So now the problem reduces to calculating the E[Xi]E[Xi] for each ii. But this is fairly easy, as

E[Xi]=1P(Xi=1)+0P(Xi=0)=P(Xi=1)=P(bin i is empty)=(1−1n)m,E[Xi]=1P(Xi=1)+0P(Xi=0)=P(Xi=1)=P(bin i is empty)=(1−1n)m,

where the last equality is because balls 1,2,…,m1,2,…,m must all go in a bin other than ii, each with probability 1−1n1−1n.

Therefore,

E[Y]=n(1−1n)m.E[Y]=n(1−1n)m.

Your second problem can be worked in a similar fashion. Let YY be the number of bins that have exactly 11 ball. Let XiXi be 11 if bin ii has exactly one ball and 00 otherwise. Then all that's left is to figure out E[Xi]E[Xi], which is the probability that a given bin has exactly 11 ball, and go from there. Since this is homework,

  • I didn't quite follow how you got the (1-1/n) term and why you raise it to power m? – Hristo Mar 25 '11 at 3:51

  • So I explained to myself the (1-1/n) term but I'm still confused on why its raised to power m... – Hristo Mar 25 '11 at 3:58

  • 6

    @Hristo: The probability that the first ball goes into bin ii is 1/n1/n, so the probability that the first ball goes into a bin other than ii is 1−1/n1−1/n. The probability that the second ball goes into a bin other than ii is also 1−1/n1−1/n. The same is true for the third, and so forth. In order for bin ii to be empty, ball 11 and ball 22 and ball 33 and so forth must all be in bins other than ii. That means you have to multiply 1−1/n1−1/n by 1−1/n1−1/n by 1−1/n1−1/n, etc., with a factor of 1−1/n1−1/n for each of the mm balls. That's (1−1/n)m(1−1/n)m. – Mike Spivey Mar 25 '11 at 3:59

  • Got it. That makes sense. Now why is that whole thing multiplied by n? Is it because this (1-1/n)^m term can happen for each bin? Since there are n bins, then each has (1-1/n)^m probability to be empty, so you get n*(1-1/n)^m? – Hristo Mar 25 '11 at 4:06

  • @Hristo: Yes. Go back to the E[Y]=E[X1]+E[X2]+⋯E[Xn]E[Y]=E[X1]+E[X2]+⋯E[Xn] equation. Since, for each ii, E[Xi]=(1−1/n)mE[Xi]=(1−1/n)m, we have E[Y]=(1−1/n)m+(1−1/n)m+⋯+(1−1/n)m=n(1−1/n)mE[Y]=(1−1/n)m+(1−1/n)m+⋯+(1−1/n)m=n(1−1/n)m. – Mike Spivey Mar 25 '11 at 4:22

Let's work out the probability there are kk balls (out of mm) in the first bin (out of nn). This is a simple binomial probability with p=1/np=1/n and 1−p=(n−1)/n1−p=(n−1)/n so the probability is (mk)(n−1)m−knm(mk)(n−1)m−knm.

The expected number of times the first bin has kk balls is the same, so the expected number of bins with kk balls is nn times this, i.e.

(mk)(n−1)m−knm−1

Add a comment
Know the answer?
Add Answer to:
Use simulations to analyze the behavior of hashing with chaining using the balls-and-bins simulations. Assume being...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 460 Math Activty 7.3 MATH ACTIVITY 7.3 Simulations in Statistics ulatives Purpose: Use spinners to generate...

    460 Math Activty 7.3 MATH ACTIVITY 7.3 Simulations in Statistics ulatives Purpose: Use spinners to generate random numbers and explore simulation problems. Materials: 1-to-4 and 1-t0-6 Spinners in the Manipulative Kit or Virtual Manipulatives. For the cardstock spinners, bend a paper clip and hold a pencil at the center of the spin- ner, as shown below 1. A certain brand of nonfat yogurt contains one of the letters A, B, C, or D on the inside of the cover. A...

  • (24 points) To be legal for certain types of prize competitions, bowling balls must be very close to 16 lb. The weights...

    (24 points) To be legal for certain types of prize competitions, bowling balls must be very close to 16 lb. The weights of bowling balls from a certain manufacturer are known to be normally distributed with a mean of 16 lb. and a standard deviation of .25 lb. A ball will be rejected if it weighs less than 15.68 lb. What is the probability that a ball will be rejected? Round your answer to two significant digits. Answer: Describe how...

  • heads in 72 tosses. 1.4 +/- 2 heads in 8 tosses is about as likely as...

    heads in 72 tosses. 1.4 +/- 2 heads in 8 tosses is about as likely as 36 +/- a. Step 1: Compare n, the number of tosses in the two cases. 72 is t imes more than 8? Submit Answer Incorrect. Tries 1/4 Previous Tries b. Step 2: Since we are counting (summing), the error will be multiplied by how much? Submit Answer Tries 0/4 heads in 72 tosses. c. Thus 4 +/- 2 heads in 8 tosses is about...

  • A helium balloon ride lifts up passengers in a basket. Assume the density of air is...

    A helium balloon ride lifts up passengers in a basket. Assume the density of air is 1.28 kg/m and the density of helium in the balloon is 0.18 kg/m. The radius of the balloon (when filled) is R-5 m. The total mass of the empty balloon and basket is my - 124 kg and the total volume is Vn 0.061 m. Assume the average person that gets into the balloon has a mass mp - 70 kg and volume Vp...

  • Option 1 or 2. Option 1: Use the NOAA data set provided, to examine the variable...

    Option 1 or 2. Option 1: Use the NOAA data set provided, to examine the variable DX32. DX32 represents the number of days in that month whose maximum temperature was less than 32 degrees F. The mean of DX32 during this time period was 3.6. Using Excel, StatCrunch, etc, draw a histogram for DX32. Does this variable have an approximately normal (i.e. bell-shaped) distribution? A normal distribution should have most of its values clustered close to its mean. What kind...

  • please draw a graph that best represents the data and please read everything to know what...

    please draw a graph that best represents the data and please read everything to know what it's about. i am confused and i need help Graphing Assignment 1: Representing the distribution of frequencies or values in a population Assignment Instructions 1. Read all of the background information about the data. 2. Read all of the tips about choosing what type of graph to draw. 3. Draw a graph that shows the distribution of tail length in a population of male...

  • need help with chart I have times of 5.3, 5.5, 4.8, 4.7, 4.8 iPad t 12:20...

    need help with chart I have times of 5.3, 5.5, 4.8, 4.7, 4.8 iPad t 12:20 PM * 54%-| くト勺 Lab 2 Home Insert Draw Layout ReviewView Table Calibri Materials Ball . Cell phone camera e Stopwatch A friend or family member to help you collect your data Procedure 1. 2. 3. Find a suitable ball that you can throw, kick, or hit straight up into the air Ask a friend or family member to capture a picture of you...

  • A helium balloon ride lifts up passengers in a basket. Assume the density of air is...

    A helium balloon ride lifts up passengers in a basket. Assume the density of air is 1.28 kg/m and the density of helium in the balloon is 0.18 kg/ml. The radius of the balloon (when filled) is R=4.9 m. The total mass of the empty balloon and basket is my - 121 kg and the total volume is Vb -0.071 m. Assume the average person that gets into the balloon has a mass mp-72 kg and volume V -0.076 m...

  • need answer for part B please! A tennis player swings her 1000 g racket with a...

    need answer for part B please! A tennis player swings her 1000 g racket with a speed of 12 m/s. She hits a 60 g tennis ball that was approaching her at a speed of 16 m/s. The ball rebounds at 36 m/s. Part A How fast is her racket moving immediately after the impact? You can ignore the interaction of the racket with her hand for the brief duration of the collision. Express your answer using two significant figures....

  • Using the previous tutorial, address the following: Imagine an experiment where three dice are tossed and...

    Using the previous tutorial, address the following: Imagine an experiment where three dice are tossed and the number on each die is recorded under Die1, Die2, and Die3. Answer the following questions about the sum of the three numbers recorded from: Die1+Die2+Die3. (Discussions allowed) Hint: Simulate this experiment 1000 times. (Use the same procedure as in the above tutorial, but for the Number of Variables, instead of 1 put 3, since we are rolling 3 dice not one). Next, create...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT