UCB CS61A 题
35123
请求高手帮帮忙, 把这题给刷了。 来在 UC B HW08 的 题目
Question 7: Linear Congruential GeneratorA common method of producing pseudo-random numbers is by means of thefollowing recurrence relation:
from operator import add, mul, moddef make_random_stream(seed, a, c, n): """The infinite stream of pseudo-random numbers generated by the recurrence r[0] = SEED, r[i+1] = (r
Question 7: Linear Congruential GeneratorA common method of producing pseudo-random numbers is by means of thefollowing recurrence relation:
- R0 = seed value
- Ri+1 = (a*Ri + c) % n where Ri denotes the ith pseudo-random number in the stream; a, c, and n are constant integers, and seed value is some initial value provided by the user or chosen automatically by the system.
from operator import add, mul, moddef make_random_stream(seed, a, c, n): """The infinite stream of pseudo-random numbers generated by the recurrence r[0] = SEED, r[i+1] = (r
3条回复