Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
dgreenberg
Luminary Alumni
Luminary Alumni

How is Rand calculated how is it seeded?

I am working on a sampling routine.

Our statistician wants to know if we can adjust the seed  - his words not mine.

His expectation is if I re-load the data in the same order and pick a random row using the same seed then it would yield the same results.

I am not sure that's going to work but figured I would post in the community to see what everyone has to say.

Thanks

Dan

1 Solution

Accepted Solutions
Anonymous
Not applicable

You can test with the QlikView Test Script and you'll see that with every reload it generates independent random values.

So the answers for your statistician are :

     No:     You cannot adjust the seed

     No:     It will not yield the same results when reloaded again

I ain't got clue how rand() actually works under the bonnet though.

***************************************************

Characters:

Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;

ASCII:

Load

if(RecNo()>=65 and RecNo()<=90,RecNo()-64) as Num,

Chr(RecNo()) as AsciiAlpha,

RecNo() as AsciiNum

autogenerate 255

Where (RecNo()>=32 and RecNo()<=126) or RecNo()>=160 ;

Transactions:

Load

TransLineID,

TransID,

mod(TransID,26)+1 as Num,

Pick(Ceil(3*Rand1),'A','B','C') as Dim1,

Pick(Ceil(6*Rand1),'a','b','c','d','e','f') as Dim2,

Pick(Ceil(3*Rand()),'X','Y','Z') as Dim3,

Round(1000*Rand()*Rand()*Rand1) as Expression1,

Round(  10*Rand()*Rand()*Rand1) as Expression2,

Round(Rand()*Rand1,0.00001) as Expression3;

Load

Rand() as Rand1,

IterNo() as TransLineID,

RecNo() as TransID

Autogenerate 1000

While Rand()<=0.5 or IterNo()=1;

View solution in original post

4 Replies
sunny_talwar

I have never done it, but tried looking it up on Google and QV's help. From the looks of it, it doesn't seem it is possible, unless there is a work around available.

Anonymous
Not applicable

You can test with the QlikView Test Script and you'll see that with every reload it generates independent random values.

So the answers for your statistician are :

     No:     You cannot adjust the seed

     No:     It will not yield the same results when reloaded again

I ain't got clue how rand() actually works under the bonnet though.

***************************************************

Characters:

Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;

ASCII:

Load

if(RecNo()>=65 and RecNo()<=90,RecNo()-64) as Num,

Chr(RecNo()) as AsciiAlpha,

RecNo() as AsciiNum

autogenerate 255

Where (RecNo()>=32 and RecNo()<=126) or RecNo()>=160 ;

Transactions:

Load

TransLineID,

TransID,

mod(TransID,26)+1 as Num,

Pick(Ceil(3*Rand1),'A','B','C') as Dim1,

Pick(Ceil(6*Rand1),'a','b','c','d','e','f') as Dim2,

Pick(Ceil(3*Rand()),'X','Y','Z') as Dim3,

Round(1000*Rand()*Rand()*Rand1) as Expression1,

Round(  10*Rand()*Rand()*Rand1) as Expression2,

Round(Rand()*Rand1,0.00001) as Expression3;

Load

Rand() as Rand1,

IterNo() as TransLineID,

RecNo() as TransID

Autogenerate 1000

While Rand()<=0.5 or IterNo()=1;

dgreenberg
Luminary Alumni
Luminary Alumni
Author

Thanks.

That is what I expected just needed some backup to explain to the statistician that we can't do that.

swuehl
MVP
MVP

Well, if you need the same sequence of "random" numbers on every reload, you could probably either

a) use a small VBScript calling RND / Randomize

or

b) create a set of numbers using QV script Rand() function, write this to a QVD and use this file