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


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

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

Extracted 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. 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="">
Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here