Question: DProb code public class DProb { public static double Permutations(long N, long X) { double perm = 1.0; for(long i = N - X +

DProb code

public class DProb {

public static double Permutations(long N, long X) { double perm = 1.0; for(long i = N - X + 1;i <= N; i++) { perm = perm * (double)(i); }

return perm; } //end permutations

public static double Combinations(long N, long X) { double comb = 1.0; long i; if(X==0||X==N) return comb; if(N-X>X) { for(i=1;i<=X;i++) comb = comb*(double)(N-i+1)/(double)(i); return comb; } else { for(i=1;i<=N-X;i++) comb = comb*(double)(N-i+1)/((double)(i)); return comb; } }

//end compbinations

public static double HyperGeometric(long Np, long Xp, long N, long X) { double probX = 0.0; probX = ((Combinations(Xp, X) * Combinations(Np - Xp, Np - X))/(Combinations(Np, N))); return probX; }

//end HyperGeometric

public static double Binomial(double P, long N, long X) { double probX = 0.0;

probX = (Combinations(N,X) * Math.pow(P,X) * Math.pow(1-P,N-X));

return probX; }

//end Binomial

public static double Poisson(double Xmean, long X) { double probX = 0.0;

probX = (Math.exp(-Xmean)*Math.pow(Xmean,X)/(Permutations(X,X)));

return probX; }

//end Poisson

public static void main(String args[]) {

//TEST CODE HERE

}

} // end class

Write a test code that uses the DProb class functions to solve several counting problems and probability problems involving discrete random variables. The problems are listed below:

1. A department contains 33 employees. The manager is going to randomly draw 4 employees and give each one a prize.

a. How many ways can the 4 employees be drawn if the order in which they are drawn matters (i.e. the prizes have different values)?

b. How many ways can the 4 employees be drawn if the order in which they are drawn does not matter (i.e. all prizes have the same value)?

2. Suppose that the CS Dept at Happy Valley State College has two computer labs. Lab-A contains 50 PC's and Lab-B contains 30 PC's. Nine of the Lab-A PC's and 4 of the Lab-B PC's have been infected with spyware. A sample of PC's will be inspected to check for spyware.

a. Suppose 8 Lab-A PC's are randomly drawn. What is the probability that none of the PC's in the sample is infected?

b. Suppose 8 Lab-B PC's are randomly drawn. What is the probability that none of the PC's in the sample is infected?

c. Suppose 4 Lab-A PC's are randomly drawn, and a separate random sample of 4 Lab-B PC's is drawn. What is the probability that none of the PC's in either sample is infected?

d. Suppose that from a combined list of all 80 Lab-A and Lab-B PC's, 8 PC's are randomly drawn. What is the probability that none of the PC's in this sample is infected?

3. A munitions warehouse contains 71 bombs, of which 5 are defective. A sample of 10 bombs will be drawn and tested.

a. What is the probability that the sample will contain exactly 2 defective bombs?

b. What is the probability that the sample will contain less than 2 defective bombs?

4. Suppose that the same munitions warehouse contains a very large number of hand grenades, of which 6.9% are defective. A sample of 30 grenades will be drawn and tested.

a. What is the probability that the sample will contain exactly 3 defective grenades?

b. What is the probability that the sample will contain less than 3 defective grenades?

5. Suppose that the munitions warehouse has just received a large shipment of a new, higher-quality hand grenade. Suppose that only 2.6% of the grenades in the shipment are defective. A sample of 125 grenades will be drawn and tested.

a. What is the probability that the sample will contain exactly 4 defective grenades?

b. What is the probability that the sample will contain less than 4 defective grenades?

Solve the problems in 5a and 5b using the Binomial distribution. Then solve the same problems using the Poisson distribution as an approximation. How good is the Poisson approximation?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!