Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago