Rnd() gives diff. op's in parallelly running Jobs vs Manager

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Rnd() gives diff. op's in parallelly running Jobs vs Manager

Post by ameyvaidya »

This post/doubt is a result of tests done for <A Href="viewtopic.php?p=156772#156772">this</A> Post
In order to test if the RND function returns unique values when called in Jobs executing simultaneously, I created a routine with Just the 2 lines:

Code: Select all

RANDOMIZE (@NULL)
Ans=RND(99999)
This routine was used in 5 instances of the same multi-instance Job using about 200 rows of input data to generate 200 random numbers per job.

A sequence calls all 5 invocations in parallel.

(and yes i had some time on my hands :roll: to try this out)

The results are documented in the above link.

The reason for this post is the strange thing I'd noticed when testing the routine I'd built for this test was that if I used randomize(@NULL) in the routine, it generates the same value across 5 different test rows(Dummy arguments and using "Run All"). If I rem'med the randomize() function, it would return unique random numbers. This is the exact opposite of what i noticed when using this routine in the 5 instanced Job

The question this raises is that how does the Manager do the Test for routines?

Does each routine call spawn a new process (i feel this is unlikely)
or
One sIngle process runs all the test rows one after the other? If so, after a test run, is this process killed and an new one started for each test run?


Any other details (pages in manuals, links to docs, etc) would be very very velcome :-)
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

From the BASIC pdf manual:
Use the RANDOMIZE statement with an expression to make the RND function generate the same sequence of random numbers each time the program is run. If no expression is supplied, or if expression evaluates to the null value, the internal time of day is used (the null value is ignored). In these cases the sequence is different each time the program is run.
So, this function sets the 'seed' that the string of (psuedo) random numbers are generated from. Same seed = same string of 'random' numbers.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I responded to the other post before replying here.

A random number generate is never random, it is pseudo-random. The algorithm distribute elements in the series as randomly as possible across the available range of numbers. But in order to be used for prediction purposes it needs to be repeatable and verifiable, thus the seed or RANDOMIZE() function.

Just like any series, if you start in the same place you will get the same numbers in the same order. Any seed you choose is going to be better than the constant value you chose.
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

Thanks, Arand and Craig.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
Post Reply