|
From: Daniel J S. <dan...@ie...> - 2006-05-12 03:28:46
|
Hans-Bernhard Br=F6ker wrote:
>> against some other result elsewhere. Researchers do that sort of=20
>> thing quite a bit, I would think. Cryptography perhaps being an=20
>> example? =20
>=20
>=20
> Nobody in a remotely sane state of mind would use a plain vanilla rand(=
)=20
> function like gnuplot's for cryptography.
I've seen a lot of insane stuff in my day. :-)
>=20
>> No, the seed and what the PRNG return are two different things. =20
>=20
>=20
> You did seem to like Octave's behaviour though, which returned the seed=
=20
> as the next random number...
No. Here:
octave:1> rand("seed",456)
octave:2> rand(1)
ans =3D 0.39089
octave:3> rand("seed",456)
octave:4> rand("seed")
ans =3D 456.00
octave:5> rand(1)
ans =3D 0.39089
The "seed" just means "show me the seed" in case I run some experiment an=
d want to know what the seed is before I start, in case I want to come ba=
ck to that.
[This is all hindsight. Don't read on if you've had enough.]
You see, the point I'm trying to make is that I've got a feeling that imp=
lementations of random number generators may historically not produce any=
kind of random value related to modifying or showing the seed.
For example, there is the Octave behavior. From some C literature is:
"srand" sets the "seed" for a pseudo-random number generator. Once the se=
ed has been set, you may call "rand" to obtain pseudo-random numbers.
>=20
>> issue is that, yes, the gnuplot PRNG is replacing the state of the=20
>> PRNG but then it immediately generates a random number that *can't be=20
>> used*. =20
>=20
>=20
> That number is just as pseudo-random as any other one coming out of the=
=20
> PRNG. And rand() being a function, it must return some value --- what=20
> else should that be?
rand() being a function as gnuplot defines functions. Mathematically it'=
s not a function. The argument should be meaningless. There should be n=
o rand(-1), rand(x>1), rand({,}) but maybe instead
set seed (standard value)
unset seed (same as set seed)
set seed # (for x>0 sets both seeds to a value based on the value of x=
)
set seed #,# (for x>0 sets seed1 to x and seed2 to y)
>=20
>> unused =3D rand(678)
>>
>> does not set the seed to 678. It sets it to whatever the seed is that=
=20
>> follows 678.
>=20
>=20
> No. Certainly not in gnuplot, because 678 can never be the output of=20
> our rand(),
The seed and the output are two different things.
> so there's no such thing as "the seed that follows" it.
Let n be the index of sequence seed(n) =3D {seed1(n),seed2(n)}. Then in =
code:
/* Generate pseudo random integers */
k =3D seed1 / 53668L;
seed1 =3D Xa1 * (seed1 - k * 53668L) - k * 12211;
if (seed1 < 0)
seed1 +=3D Xm1;
k =3D seed2 / 52774L;
seed2 =3D Xa2 * (seed2 - k * 52774L) - k * 3791;
if (seed2 < 0)
seed2 +=3D Xm2;
which means seed(n+1) =3D f(seed(n)).
Dan
|