samedi 9 juillet 2016

PRNGs and seed values

I am using the following PRNG in a Lua script:

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

My question is, do similar seed values produce similar results when run through a PRNG like this?

I mean, the numbers 3 and 5 are close to each other compared to a large number like 3001. Are the first two numbers likely to produce similar pseudo random values?

Thanks.




Aucun commentaire:

Enregistrer un commentaire