Question: Problem 4 Coding Assignment: In this problem you will develop code to generate random numbers that follow a particular distribution. Common programming languages provide you

 Problem 4 Coding Assignment: In this problem you will develop code

Problem 4 Coding Assignment: In this problem you will develop code to generate random numbers that follow a particular distribution. Common programming languages provide you with a (pseudo) random number generator that yields a uniformly distributed random variable. This question is about using such capability to develop a generator for arbitrarily distributed random vari- ables a) Write a Java function with the following prototype: double exp(double lambda), that returns a random value that is distributed according to an exponential distribution with a mean of T - (Hint: An approach for doing this is provided in the lecture notes). The value of A will be passed as a parameter to your code. The function should be implemented in its own java file, named exp.java Apart from implementing the function itself, the class should also include a main(...) function. The main(...) function should accept 1 parameter from the calling environment, i.e. a double holding the value of A It is responsibility of the main(...) function to internally invoke the implemented exp(...) function only once, and to print its result. Nothing else should be printed in the console, except the value returned by exp(...) in decimal format. b) Write a Java function with prototype: double custom (double [] outcomes, double [] probabilities), that returns a random value that is distributed according to an arbitrary distribution described in a table of discrete values/outcomes (for the random variable) and the probability of those values. (Hint An approach for doing this is provided in the lecture notes). The function should be implemented in its own java file, named custom.java. Apart from implementing the function itself, the class should also include a main(...) function. The main(...) function should accept 10 parameters from the calling environment. These 10 parameters represent 5 pairs of outcome values and associated probabilities. For instance, the custom distribution given in Table 1 is given in input in the following way: 5 0.16 10 0.13 20 0.22 40 0.20 70 0.29 Outcome Probability 10 20 40 70 0.16 0.13 0.22 0.20 0.29 Table 1: A custom probability distribution It is responsibility of the main(...) function to internally invoke the implemented custom(...) function only once, and to print its result. Nothing else should be printed in the console, except the value returned by custom(...) in decimal format

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!