Reproducible ramdomisation

majhl

Registered User.
Local time
Today, 09:09
Joined
Mar 4, 2008
Messages
89
I need to randomise participants to two groups which we can call 'A' and 'B'. As a further complication, I need to use 'block randomisation'. If you use blocks of four for example, they are 6 different patterns possible:

AABB, BBAA, ABAB etc etc.

If you then generate a random number between 1 and 6 and the result is '2', this simply means you will use the second block above (BBAA). From then you can a number of things. You can allocate the next four participants into this block for example. Participant 1 goes into group B, the next into group B and so on.

But the actual methodology here isn't the issue.

The problem I'm having is that the randomisation should be reproducible. This means that if the randomisation were to be repeated, the same people have to be randomised into the same groups.

Generating a random between 1 and 6 number is OK:

Randomize
RandVal = Int((6 * Rnd) + 1)

The difficulty I'm having is to produce the exact same sequence of random numbers. I understand that what I need to do is ensure that the same initial seed value is being used when randomising. I have tried the following with no luck (the sequence on numbers I'm generating is not always the same):

Randomize
RandVal = Int((6 - 1 + 1) * Rnd + 1)

Can anyone tell me what the exact syntax should be to achieve the desired result?

Thanks very much,

Mo
 
Try taking out the Randomize statement, that is setting a different seed value each time it's called.
 
Thanks for the response.

I have removed the 'Randomize' statement as you suggest and the results are strange to say the least.

I do not get the same sequence of numbers each time I run the code. The results returned may be the same on two or three or four different times, but then it will throw up a sequence which is completely different!

Any ideas why this should be?
 
Not to be too harsh, but "randomisation should be reproducible" is a contradictory statement. Random is exactly that...random. What you are describing is a set pattern and not really "Random", what I might do in your situation is generate an initial random pattern of data for a given group and save that pattern in a table, then referenece it through a dlookup or recordset object.
 
Not to be too harsh, but "randomisation should be reproducible" is a contradictory statement. Random is exactly that...random. What you are describing is a set pattern and not really "Random", what I might do in your situation is generate an initial random pattern of data for a given group and save that pattern in a table, then referenece it through a dlookup or recordset object.


Yes I understand that there is something of contradiction in the expression I used. Perhaps pseudo-randomisation is better? But as I understand it, the random number generator in Access in pseudo-random anyway.

And this doesn't really explain the results I'm getting when Access help files tell me that a piece of code should produce the same sequence of numbers.

Thanks for your suggestion though - it be that cycling through a recordset of random numbers that I generated before would be the thing to do.

Mo
 

Users who are viewing this thread

Back
Top Bottom