Random Number Generation

  • 2,845 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,845
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. By: Kishoj Bajracharya (062-BCT-515)Q. No: 1) Use the linear congruential method to generate the sequence of three two-digit randomintegers assuming Xo=27, a=8, c=47 and m=100.Solution:Given, Xo = 27, a = 8, c = 47, m = 100Using formula, Xi = (a * Xi-1 + c) mod(m) X1 = (8 * 27 + 47) mod (100) = 263 mod (100) = 2.63 Quotient = 2; Remainder or Residue = 63 X1 = Residue = 63; X2 = (8 * 63 + 47) mod (100) = 551 mod (100) = 5.51 Quotient = 5; Remainder or Residue = 51 X2 = Residue = 51; X3 = (8 * 51 + 47) mod (100) = 455 mod (100) = 4.55 Quotient = 4; Remainder or Residue = 55 X = (27 63 51 55)The three two-digit random integers we are looking for are 63, 51 and 55.Q. No: 2) Use the multiplicative congruential method to generate the four three-digit random integersassuming Xo=117, a=43, and m=1000.Solution:Given, Xo = 117, a =43, m = 1000Using formula, Xi = (a * Xi-1) mod(m) X1 = (43 * 117) mod (1000) = 5031 mod (1000) = 5.031 Quotient = 5; Remainder or Residue = 31 (2-digit) X1 = Residue = 31; X2 = (43 * 31) mod (1000) = 1333 mod (1000) = 1.333 Quotient = 1; Remainder or Residue = 333 (First 3-digit Random Number)
  • 2. By: Kishoj Bajracharya (062-BCT-515) X2 = Residue = 333; X3 = (43 * 333) mod (1000) = 14319 mod (1000) = 14.319 Quotient = 14; Remainder or Residue = 319 (Second 3-digit Random Number) X3 = Residue = 319; X4 = (43 * 319) mod (1000) = 13717 mod (1000) = 13.717 Quotient = 13; Remainder or Residue = 717 (Third 3-digit Random Number) X4 = Residue = 717; X5 = (43 * 717) mod (1000) = 30831 mod (1000) = 30.831 Quotient = 30; Remainder or Residue = 831 (Fourth 3-digit Random Number) X = (117 31 333 319 717 831)The four three-digit random integers we are looking for are 333, 319, 717 and 831.Q. No: 3) Use the mixed congruential method to generate a sequence of three two-digit randomnumbers with Xo=37, a=7, c=29 and m=100.Solution:Given, Xo = 37, a = 7, c = 29, m = 100Using formula, Xi = (a * Xi-1 + c) mod(m) X1 = (7 * 37 + 29) mod (100) = 288 mod (100) = 2.88 Quotient = 2; Remainder or Residue = 88 X1 = Residue = 88; X2 = (7 * 88 + 29) mod (100) = 645 mod (100) = 6.45 Quotient = 6; Remainder or Residue = 45 X2 = Residue = 45; X3 = (7 * 45 + 29) mod (100) = 344 mod (100) = 3.44 Quotient = 3; Remainder or Residue = 44
  • 3. By: Kishoj Bajracharya (062-BCT-515) X = (37 88 45 44)The 3 two-digit random numbers we are looking for are 88, 45, and 44.