
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:H
10:07
••.
o Define the cumulative sums
Si
= a1 + a2+...+ ai and
So = 0.
Pick a random integer r uniformly
between 0 and Sn – 1.
-
o Find the unique index i between 1
and n such that S;-1 <r < S;.
Geometrically, this subdivides the
interval [0, Sn) into n subintervals
[S;-1, S;), with the length of
subinterval i proportional to a¡. For
example, if the discrete distribution
is defined by
(а1, а2, аз, а4, аs , а6) — (10, 10, 10, 10, 1
then the cumulative sums are
(S1, S2, S3, S4, S5, S6) = (10, 20, 30, 40,
and the following diagram
illustrates the 6 subintervals:
Pick a random integer r between 0 and S, - 1.
1 if 0sr< 10
4 if 30 sr< 40
6 if 50 sr< 100
10
20
30
40
50
100
So
S2
S3
Ss
S6
In probability theory, this is known
as sampling from a discrete
distribution.

Transcribed Image Text:(€)
10:06
••.
1. Discrete distribution. Write a
program DiscreteDistribution.java
that takes an integer command-line
argument m, followed by a
sequence of positive integer
command-line arguments
a1, a2,..
random indices (separated by
whitespace), choosing each index i
with probability proportional to a¡.
An, and prints m
9 •• •
-/Desktop/arrays> java DiscreteDistribution 25 1 1 1 111
5 2 4 4 5 5 4 3 4 3 1 5 2 4 2 6 1 3 6 2 3 2 4 1 4
~ /Desktop/arrays> java DiscreteDistribution 25 10 10 10 10 10 50
3 6 6 16 6 2 4 6 6 3 6 6 6 6 4 5 6 2 2 66 2 6 2
-/Desktop/arrays> java DiscreteDistribution 25 80 20
1 2 1 2 1 1 2 1 1 1 1 1 1 11 2 2 2 1 111111
~/Desktop/arrays> java DiscreteDistribution 100 301 176 125 97 79 67 58 51 46
6 2 4 3 2 3 3 1 7 1 1 3 47 1 4 2 2 1 1 3 1 8 6 2
1 3 6 185 1 3 6 1 1 2 3 8 7 4 6 4 3 1 5 3 3 7 3
1 3 177 2 2 3 6 5 4 1 1 1 7 2 3 5 2 2 1 4 1 2 1
2 1 2 2 3 2 8 4 3 2 1 8 3 5 3 3 8 1 2 3 3 1 2 3 1
To generate a random index i with
probability proportional to a;:
o Define the cumulative sums
S; =
a1 + a2 +...+ a; and
0.
So
Pick a random integer r uniformly
between 0 and Sn – 1.
o Find the unique index i between 1
and n such that S;-1 < r < S¿.
-
Geometrically, this subdivides the
interval [0, Sn) into n subintervals
[S;-1, S;), with the length of
subinterval i proportional to aj. For
example, if the discrete distribution
is defined hy.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- write a program (its name should be StudentPoll.java) that first reads an integer, N, for the number of responses from students and then creates an array of N elements of type int to store the responses. Use SecureRandom to generate N random integers of values between 3 and 10 inclusive as the response values (i.e., the survey values) for the array. The program should print out the distribution of the survey like the following outputs. public class StudentPoll {public static void main(String[] args) {// student response array (more typically, input at runtime)int[] responses = {1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3, 2, 3, 3, 2, 14};int[] frequency = new int[6]; // array of frequency counters // for each answer, select responses element and use that value// as frequency index to determine element to increment for (int answer = 0; answer < responses.length; answer++) { try { ++frequency[responses[answer]]; } catch (ArrayIndexOutOfBoundsException e) { System.out.println(e); //…arrow_forwardJava Program ASAP Modify this program so it passes the test cases in Hypergrade becauses it says 5 out of 7 passed. Also I need one one program and please correct and change the program so that the numbers are in the correct places as shown in the correct test case. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.InputMismatchException;import java.util.Scanner;public class FileSorting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Please enter the file name or type QUIT to exit:"); String fileName = scanner.nextLine(); if (fileName.equalsIgnoreCase("QUIT")) { break; } try { ArrayList<String> lines = readFile(fileName); if (lines.isEmpty()) { System.out.println("File " +…arrow_forwardWrite a program that will read a line of text and output the number of words in the line and the number of occurrences of each letter. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma, or the beginning or end of the line. You can assume that the input consists entirely of letters, whitespace, commas, and periods. When outputting the number of letters that occur in a line, be sure to count uppercase and lowercase versions of a letter as the same letter. Output the letters in alphabetical order and list only those letters that occur in the input line. For example, the input line I say Hi. should produce output similar to the following: 3 words 1 a 1 h 2 i 1 s 1 yarrow_forward
- Java Programming: Write a lexer that prints out the shank.txt. Below is the shank.txt that needs to be printed out as a series of tokens and attached is the rubric of all the components the lexer needs to have. Shank.txt Fibonoacci (Iterative) define add (num1,num2:integer var sum : integer)variable counter : integerFinonacci(N)int N = 10;while counter < Ndefine start ()variables num1,num2,num3 : integeradd num1,num2,var num3{num1 and num2 are added together to get num3}num1 = num2;num2 = num3;counter = counter + 1; GCD (Recursive) define add (int a,int b : gcd)if b = 0sum = asum gcd(b, a % b) GCD (Iterative) define add (inta, intb : gcd)if a = 0sum = bif b = 0sum = awhile counter a != bif a > ba = a - b;elseb = b - a;sum = a;variables a,b : integera = 60b = 96subtract a,barrow_forwardwrite a java class definition 4. Give the class definition of ArrayChecker which has an integer array variable arr. This has 2 methods a. Constructor which take an integer parameter numElements and reads all the numElements from the user using Scanner class into arr. b. public boolean checkConsecutiveValues (int n), which checks whether arr has atleast n consecutive elements with the same values. (it is enough if it returns the first occurrence of n consecutive elements) (Write only the class definition of ArrayChecker) Eg. 12345555 10, if n = 4, this has four consecutive 5s, return true 10 12 111 11456666. If n = 3, this has 3 consecutive 1s, return true. 10 12 111 11456666. If n = 7, then return falsearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education