Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

******* Please write the code, I have posted this question before and no code was written. *******I would like to check the code I have

******* Please write the code, I have posted this question before and no code was written.

*******I would like to check the code I have already written with the code you come up with

*******Posted the question twice before and didn't have any code written. I would like to check mine with yours

******** Thank you SO much!!!

Write a Binomial class to implement a Binomial random variable. Private instance variables for the class should include: double P - probability of a success in any one trial. long N - number of independent trials. long X - the number of successes in the N trials.

The class methods should include: appropriate constructor(s). appropriate get and set methods for the instance variables. long randomX() - generates a new random value for X. double mean() - calculates the mean of the random variable [= N*P]. double variance() - calculates the variance of random variable [= N*P*(1-P)]. double probX() - calculates the Binomial probability for the current X value.

Write a program that uses the Binomial class to solve the following problems:

1. For the Binomial distribution defined by P = 0.36 and N = 22: a. Output P and N. b. Generate a random value for X, and then output that value. c. Output the mean of the distribution. d. Output the variance of the distribution

2. For the Binomial distribution defined by P = 0.73 and N = 6, output the probability distribution of X. That is, for each value of X from 0 to 6, show the X-value together with the probability for that value.

Output format should be:

X Pr(X)

0 ...

1 ...

... ...

6 ...

3. For the Binomial distribution defined by P = 0.32 and N = 12: a. Generate 100 random variable values. b. Calculate the average of these generated values [= (X1 + X2 + ... + X100)/100]. c. Calculate the theoretical mean of this probability distribution using the mean() method. d. Compare the values obtained in 3b and 3c. How close are they? Why aren't the values identical?

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions