跳到主要內容

發表文章

目前顯示的是 4月, 2015的文章

ITSA_38_Pro5

[Problem 5] Pseudo Random Generation 成績: 0 / 倒扣: 0.8 Problem Description Random numbers are usually used in computer program. Computer can't produce pure random numbers but can produce pseudo random numbers. There are some pseudo random generators in our program language library which are usually used. There is a method which is usually used to produce pseudo random numbers. The method is called linear congruential method. This method needs 4 parameters: m   a   c   X 0 a modulus   a multiplier   a addend   a initial number(seed number) m   > 0 0 <   a   <   m 0 ≤   c   <   m 0 ≤   X 0   <   m The pseudo random numbers are produced by follow program states:   X n +1   = (   aX n   +   c   ) mod   m   For example, if   a   = 7,   c   = 5,   m   =12, and   X 0   = 4 then the program produces a series of the pseudo random numbers as follow: X n aX n   + c X n+   1   =   (   aX n   +   c   ) mod   m 4   9 8 1 0 5 33   68   61 12   5