Question: PLEASE HELP WITH QUESTION 3-5 onle please ** please use the java classes under this to help answer the questions. thanks // Discrete Probability Library

PLEASE HELP WITH QUESTION 3-5 onle please

** please use the java classes under this to help answer the questions. thanks

PLEASE HELP WITH QUESTION 3-5 onle please ** please use the java

// Discrete Probability Library

public class DProb

{

public static double Permutations(long N, long X)

{

double perm = 0.0;

return perm;

}

public static double Combinations(long N, long X)

{

double comb = 0.0;

return comb;

}

public static double HyperGeometric(long Np, long Xp, long N, long X)

{

double probX = 0.0;

return probX;

}

public static double Binomial(double P, long N, long X)

{

double probX = 0.0;

return probX;

}

public static double Poisson(double Xmean, long X)

{

double probX = 0.0;

return probX;

}

} // end class

Write a Java "library" class called DProb consisting entirely of static methods (similar to a C function library). This type of class is never instanced as an object, so references to methods use the class name instead of an object name (e.g. DProb.xxx(..)). The DProb class contains functions for calculating permutations, combin ation s, and several discrete probability distri butions. For each function, use a long datatype for all integer parameters and a double datatype for all decimal parameters. Do not use factorial functions in your algorithms (overflow problems). The return type is double for each function. Your DProb class shoul d inclu de the following functions: Permutation(long N, long x): This function returns the number of ways X objects can be drawn from N objects in a particular order. To reduce the problem of integ er overflow, your algorithm should convert (cast) all values to double while you calculate the result. 1. eg. double perm 1.0 Then in loop: perm-perm(double) (N-i) 2. Combination(long N, long x): This function returns the number of ways X objects can be drawn from N objects ignoring the order in which the objects are drawn. To reduce the problem of integer overflow, your algorithm should: a. For special cases X = 0 and X = N, the return value is 1.0 b. Calculate CNX) or CNN-X) depending on whether X or N-X is smaller (sam e value) e.g To calculate C(50,47), calculate C(50,3) instead eg. C(25,4)- 25/1 24/2 * 23/3 22/4 eg. double comb - 1.0 c. Alternate multiplies and divides (in a loop) d. Convert (cast) all values to double while you calculate the result Then in the loop: combcomb* (double) (N-i)/ (double) (i 1) 3. HyperGeometric (long Np, long p, long N, long X): This function returns the hyperg eometric probabilitv of having a total of X successes in a sample of size N, where the sample is drawn (without replacem ent) from a population of size Np con taining Xp successes In this probability distribution, Np, Xp, and N are fix ed, and X is the random variable 4. Binomial (double P, long N, long x): This function returns the binomial probability of having a total of X successes in N independent trials, where P is the probability ofa success in each trial. In this probability distribution, P and N are fixed, and X is the randonm variable 5. Poisson (double Xmean, long x): This function returns the Poisson probability of having a total of X independent occurrences in a fixed-size time interval (e.g. X arrivals in a 10-minute interval). The parameter Xmean is the expected (average) number of occurrences per time interval. In this probability distribution, Xmean is fixed, and X is the random variable. The Poisson function can be used to approxim ate a Binomial probability when N is large and P is small (eg. N> 100 and P05). In this case, let Xmean - N*P, and use the Poisson functiorn

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!