|
From: Daniel J S. <dan...@ie...> - 2006-05-12 00:12:45
|
Another observation: setting the seed of rand() is slightly clumsy, from what I see so far.
Certainly, it doesn't make sense to set the seed, e.g., rand(123), as part of a plot function because it will simply be drawing the same sample time and again. So, it seems that whenever rand() is used to seed the random number generator it should be on its own.
gnuplot doesn't accept "rand()" as a command. (Perhaps it should.) That means we need something like
notusedval = rand(123)
Correct?
Then there is a small technicality here, but it may be important from a community use standpoint. Looking at the code in specfun.c, I notice that ranf() called with a seed will 1) set the seed, then 2) draw a random sample starting from that seed.
So, if I understand this correctly, the command above
notusedval = rand(123)
after it is called will not have a seed of 123, but actually something different. OK, so someone says "Oh, you're using the such and such generator. Set the seed to X then draw 50 samples." But I can't do that. If I have to call rand(123) on its own and it draws a sample, the seed is no longer 123.
Take a look at these commands from Octave:
octave:2> rand(3)
ans =
0.96431 0.15260 0.54168
0.14526 0.66702 0.18013
0.47766 0.35227 0.73535
octave:3> rand("seed",123)
octave:4> rand("seed")
ans = 123.00
octave:5>
I'm not trying to say the Octave/gnuplot generators should be the same, but notice that rand() called when setting the seed apparently doesn't draw any samples and then showing the seed indicates, yes, the seed is currently 123.
Now, back to the syntax. Maybe seeding the generator should be something like
gnuplot> rand(123)
which does not draw a random sample but leaves the seed at 123, and
gnuplot> notusedval = rand(123)
should be an invalid command.
Dan
>> 6) Would anyone object to a patch for a math function "randn()"
>> generating unit variance normal distribution random values using the
>> Box-Mueller method?
>
>
> I would: it's not needed. You have rand(), you have invnorm, that's all
> you need. Also see 'stat.inc'.
|