Question: Create a class called BernoulliRandomVariable in a class file called BernoulliRandomVariable.java that extends the class DiscreteRandomVariable. This class should have the following fields/methods: One Field

Create a class called BernoulliRandomVariable in a class file called BernoulliRandomVariable.java thatCreate a class called BernoulliRandomVariable in a class file called BernoulliRandomVariable.java that extends the class DiscreteRandomVariable. This class should have the following fields/methods: One Field - double p (where p stands for the probability of success) One method called getMean() - accepts no arguments - returns a double - calculates and returns the mean for a Bernouilli random variable with parameter p using the following equation: E[X] = p where X is a Bernoulli random variable

One method called getVariance() - accepts no arguments - returns a double - calculates and returns the variance for a Bernoulli random variable with parameter p using the following equation: V [X] = p(1 - p) where X is a Bernoulli random variable One method called PMF() - accepts an integer named x - returns a double equal to the value of P(X = x) - calculates P(X = x) using the following equations: P(X = x) = p for x = 1 P(X = x) = 1 - p for x = 0 P(X = x) = 0 for x 1 Default constructor - accepts no arguments - returns nothing - initializes p to 0 - sets mean to its correct value by calling getMean() - sets variance to its correct value by calling getVariance()

Parameterized constructor - accepts one double as an argument - returns nothing - initializes p to value passed to the constructor - sets mean to its correct value by calling getMean() - sets variance to its correct value by calling getVariance() One method that overrides printSummary() - accepts no arguments

-prints to the screen \Random Variable Summary Information:" with a newline at the end of the statement - prints to the screen \Random Variable Type: Discrete" with a newline at the end of the statement - prints to the screen \Distribution: Bernoulli" (with p replaced by the value in the field p) with a newline at the end of the statement - prints to the screen \Mean: " (with replaced by the value in the eld mean) with a newline at the end of the statement { prints to the screen \Variance: 2" (with 2 replaced by the value in the eld variance) with a newline at the end of the statement

public class piscreteRandomVariable extends RandomVariable {j public DiscreteRandomVariable() { super(); D public void printSummary(){ System.out.println("Random Variable Summary Information:"); System.out.println("Random Variable Type: Discrete"); public class piscreteRandomVariable extends RandomVariable {j public DiscreteRandomVariable() { super(); D public void printSummary(){ System.out.println("Random Variable Summary Information:"); System.out.println("Random Variable Type: Discrete")

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!