[Solved]Don T Understand Assignment Make Code Api Uses Calculations Overview Testing Parts Assignm Q37239018
I don’t understand how to do this, the assignment is to make thecode with the API and uses the calculations in the overview. thenyou do the testing parts. this is the assignment sheet our teachergave us. and the picture of the book is the RandomWebSurferDD thatis reffered to in the question.



op4- Cs 1113 Computer Science I Spring 2019-Google Crome https:/Fanline.okstate.edu/d2l/le/content/237568/fullscreen/2657387/Niew pp4 PROGRAMMING PROBLEM CS 1113, 2019 Fall Due: April 28. 11:59 p.m Alternatives to replace PP score your average homework score can replace the score of PP4 or the score of your final eram can replace the score of PP if not used to replace an eaTher eran Overview:Discrete distribution (Excrcise 4.2.38). Design a fast algorithm to repeatedly generate numbers from the discrete distribution: Given an array a[] of non-negative real numbers that sum to 1, the goal is to return index i with probability a[i]. Form an array sum [] of cumulated sums such that sum[i] is the sum of the first i clements of a[]. Novw generate a random real number r between 0 and 1, and use binary scarch to return the index i for which sumlil r< sum[i+1]. Compare performance of this approach with the approach taken in RandomSurfer (Program 1.6.2) Details: create a class to provide your implementation. Call the class DiscreteDistribution. Provide the following API public class DiscreteDistribution DiscreteDistibution(doublell a) constructor: initialize sun array int sample) discrele distribution based on fast algorilhn recalculate cumulalive sum for arTay a voidedoublell ) Testing In the main nethod of DiscreteDistribution, rovide the following test of the API Test 1, create an array 1.0/6.0,1.0/6.0,1.0/6.0, 1.0/6.0,1.0/6.0,1.0/6.0 lo rep- rseni lhe probabilities of fair six sided die. Create DiscreteDistribution object using that array. Sample the distribution 1000 times and print out the uencios of the rcturned indicos :19 PM 4/22/2019 O Type here to search op4- Cs 1113 Computer Science I Spring 2019-Google Crome https:/Fanline.okstate.edu/d2l/le/content/237568/fullscreen/2657387/Niew pp4 Test 2, create an array 1.0/9.0,2.0/9.0, 1.0/9.0,3.0/9.0,1.0/9.0,1.0/9.0 o rep resent the probabilities of an unfair six sided die. Reuse the discrete distribution object from t he first test by using reset with the new往rray. Salliple the distri- bution 1000 ti aud print outte frequencies of the retud ndics . Conduct a perforn est on RandomSurfer by Test 3: Deter the order of growth of the ru ti ofhe origial code of the for trials loop with respect to . That is, start iin after the data has been read from StdIn aud right before the for loop starts. Measure he tie after the for loop finishes and before the results are printed ont. Perform the time test by varying the values of n. Record the results and your growth estimate in an answers.txt file – Test 4: create an alternative called RandomSurferDD that uses your implen tation of the discrete distribution to replace the lincar scarch (the for j loop) Note: you will an array of DiscreteDistribution objects, one for cach row of p. Determine the order of growth of the running time of the modified code of the :19 PM 4/22/2019 O Type here to search op4- Cs 1113 Computer Science I Spring 2019-Google Crome https:/Fanline.okstate.edu/d2l/le/content/237568/fullscreen/2657387/Niew pp4 p. Determine the order of growth of the running time of the modified code of the for trials loop with respect to n. Record the resnlts and your growth estimate in an answers.txt file Submit: the soure code files DiscreteDistribution.java, RandomSurferDD.java, and the text answers.txt file to Dropbox on Brightspace Grading Guidelines Programs compiles on command line Program submitted on D2L Proper Method behavior: Required for non-zero score Required for non-zero score Constructor 10% sample 30% reset 10% test client (main method) 20% 20% 10% RandomSurferDLD answers.txt :19 PM A/22019 O Type here to search e Study: Random Web Surfer Ca 175 1.6.2 Simulating a random surfer public class RandomSurfer public static void mai n(Stringt] args) Simulate random surfe int trials Integer.parseInt (args[0]): int n StdIn.readInt); StdIn.readInt); // Read transition matrix doubletl[] p new double[n]In]; for (int i 0; i <n; i++) trials mumber of moves n mumber of pae page current page probability that the p[i]Ij] surfer moves from page i to page j for (int j 0; j< n; j++) umber of times the freq[1] surfer hits page p[illj] StdIn.readDoubleO int page0; intl] freq new int[n]; for (int t 0; t < trials; t++) // Make one random move to next page double r Math.randomO; double sum 0.0 for (int j 0; j < n; j++) // Find interval containing r sump[page] [jl: if (r < sum) { page = j: break; } freq[page]++; // Print page ranks for (int į -0; į < n; İ++) dStdOut.printf(“%8.5f”, (double) freq [1] / trials); StdOut.printlnO: n uses a transition matrix to simulate the behavior of a random surfer. it takes ment, reads the transition matrix, performs the hmber of moves as prescribed hy the matris, and prins the relative frequeny of page. The key to the computation is the random move to the next page (see tex /his he ioves as a command-line argu Show transcribed image text op4- Cs 1113 Computer Science I Spring 2019-Google Crome https:/Fanline.okstate.edu/d2l/le/content/237568/fullscreen/2657387/Niew pp4 PROGRAMMING PROBLEM CS 1113, 2019 Fall Due: April 28. 11:59 p.m Alternatives to replace PP score your average homework score can replace the score of PP4 or the score of your final eram can replace the score of PP if not used to replace an eaTher eran Overview:Discrete distribution (Excrcise 4.2.38). Design a fast algorithm to repeatedly generate numbers from the discrete distribution: Given an array a[] of non-negative real numbers that sum to 1, the goal is to return index i with probability a[i]. Form an array sum [] of cumulated sums such that sum[i] is the sum of the first i clements of a[]. Novw generate a random real number r between 0 and 1, and use binary scarch to return the index i for which sumlil r
Expert Answer
Answer to I don’t understand how to do this, the assignment is to make the code with the API and uses the calculations in the over… . . .
OR

