## Requirement

Feel free to make assumptions, if you feel that such assumptions are justified or necessary. Please state your assumptions clearly. Unreasonable assumptions lead to unreasonable grades!

## Simulation of coin tosses.

Write a Java method with the following function signature:

The above method takes in as input the number of tosses in a Bernoulli experiment and the probability of observing a heads on a single toss. The method returns back the number of heads observed when a single Bernoulli trial of 8 tossess is conducted. Note the number of heads returned back is not an expected value but the actual value (0 ≤ numberOf Heads ≤ 8) that is observed in that specific Bernoulli trial. Because this answer will vary (due to different number that gets generated via the uniform random number generator), you are asked call your method singleSimulationOfGetNumberOfHeads, 200 times for the same probability and record the results. We are providing you psuedocode of how your main function will look like that calls singleSimulationOfGetNumberOfHeads 200 times.

Generate a graph (using Excel or any of your favourite graph plotting software) of the probability of observing heads on the X axis against the number of heads observed. Note: That for each probability of heads observed on the X axis, you will record 200 values on the Y axis (because you called your getNumberOfHeads method 200 times).

If you observe 7 heads show up out of 8 tosses. What would you expect on an average for the probability of the coin showing heads? No math is required for this question. I just expect you to see the graph generated earlier and answer your question based on the graph.

Explain by observing the graph you generated, what number of heads you roughly expect to see if the coin is a fair coin. No math is required for this question. I just expect you to see the graph generated earlier and answer your question based on the graph.

## Question 1

The availability of a web server is rated at 98%. Answer the following questions

• (a) What is the probability that in a sequence of 20 connections to the web server, no connections will be refused.
• (b) What is the probability that in a sequence of 20 connections to the web server, exactly one connection will be refused.
• (c) What is the probability that in a sequence of 20 connections to the web server, at most three connections will be refused.
• (d) What is the probability that the web server will be able to successfully respond to 4 (or more) consecutive requests for connections.
• (e) What is the average number of requests that will be successfully served before a connection is refused?
• (f) What is the average number of requests that will be successfully served out of a set of 50 requests for connections?
• (g) What is the probability that out of a very large number of requests at least 98.5% of the requests will be processed successfully?
• (h) Which of the above questions refers to the reliability of the web server?

## Question 2

The arrival of packets at an Ethernet adapter of a web server is described by a Poisson process with a rate of 100 packets per second. Answer the following questions

• (a) Write down the formula for the probability distribution of the number of packets arriving to the adapter in 10 milliseconds.
• (b) What is the probability that more than 1 packet will be received within a 10-millisecond period of time?
• (c) Write down the formula for the probability distribution of the inter-arrival time of packets.
• (d) What is the probability that two packets will be separated by more than 15 milliseconds?
• (e) What is the standard deviation of the inter-arrival time of packets?

## Question 3

Packets that arrive to the Ethernet adapter described in the above problem (3) are queued up in a buffer until processed by the Interrupt Service Routine (ISR). Assuming that the ISR service time per packet is exponential with an average of 9.6 milliseconds. Answer the following questions:

• (a) What is the capacity of the Ethernet adapter?
• (b) Write down the probability distribution of the number of packets at the Ethernet adapter (either queued or being transmitted).
• (c) How many packets do you expect to find waiting in the buffer of the adapter at any point in time (on average)?
• (d) What is the average waiting time in the buffer (i.e., how long is a packet buffered untilthe ISR starts processing it)?
• (e) What is the slowdown caused by queuing at the Ethernet adapter?

## Question 4

Write a Java function that returns a random value that is distributed according to an exponential distribution with a mean of T = 1 . Hint: Given that all you have through Java is a uniform random number generator, you will need to find the relationship that maps a uniform random variable that ranges from 0 to 1 to an exponential random variable with mean T = 1 . As explained in the lecture notes, pages 9 10, one way of establishing this relationship is to equate the cumulative distribution functions for a uniformly distributed random variable (say Y) and an exponentially distributed random variable (say X).