PRNG는 종자 값 :내가 루아 스크립트에서 다음과 같은 PRNG를 사용하고
inputseed = {763261}
seedobja = 1103515.245
seedobjc = 12345
seedobjm = 4294967.295 --0x100000000
function srandom(seedobj, fVal1, fVal2)
seedobj[1] = mod(seedobj[1] * seedobja + seedobjc, seedobjm)
local temp_rand = seedobj[1]/(seedobjm - 1)
if (fVal2) then
return floor(fVal1 + 0.5 + temp_rand * (fVal2 - fVal1))
elseif (fVal1) then
return floor(temp_rand * fVal1) + 1
else
return temp_rand
end
end
-- the returned value should be a float between 0 and 1
local randomvalue_a = srandom(inputseed)
-- the returned value should be an integer between 10 and 20
local randomvalue_b = srandom(inputseed, 10, 20)
이 같은 PRNG를 실행할 때, 유사한 종자 값이 유사한 결과를 않는 내 질문?
숫자 3과 숫자 5는 3001과 같이 큰 숫자에 비해 서로 가깝습니다. 처음 두 숫자는 비슷한 의사 랜덤 값을 생성합니까?
감사합니다.
발전기가 내게 제대로 보이지 않습니다. 정수 LCG를 기반으로하지만 부동 소수점에 맞지 않는 것으로 보입니다. – sh1