So far everything works out and it does exactly what i want. But, i did my survey 26 times and i noticed huge differences between the 3 groups. The first group of questions appeard 13 times the second 5 times and the third 8 times.
This isn't really surpising, is it? n=26 is a fairly small sample and thus a not so even distribution isn't overly suprising in this case.
You need big numbers to get a fairly even distribution, but even then it is not guaranteed. That is how random numbers work.
With each draw of the random number, each number has the same chance to be drawn. So while commonly people would be surprised if the same number would be drawn 3 or 4 times in a row, this isn't that suprising at all. Each time, there was a 33,333% chance that it is the same number as before. Which is lower than the chance of 66,66% that another number is drawn, but it is still fairly high.
I did not understand the difference between my first code and my second if i am honest and i don´t know if any of them are better suited for a more even distribution. Is there anything I can do generally better or is this just the way how things work?
The difference between the two codes will not improve / worsen the distribution. What the first code does is to check if there is already a random number stored in the question. If so, it will take the already stored number, if not (so the question is currently empty) it will create a random number.
This is important, because the random number is drawn every time you "touch" the question that creates the random number. This means, depending in your survey, the random number might chance throughout the survey.
E.g. imagine you draw the random number at the beginning, let's say it is "2". Later in the questionnaire you access it again (e.g. for a relevance equation to show/hide a certain question or question group). I this case the equation will be calculated again and there is again an equal chance of 33,3% for 1, 2 or 3 to be drawn. If you use this random number just once, this has not a huge impact on your survey, but if you want to use the random number more than once in the survey, it is absolute essential to use this code (and if you allow to go back in the questionnaire as well):
Code:
{if(is_empty( randnumber.NAOK ), rand(1, 3), randnumber.NAOK )}
and never just
I see very little chance to make the random number more equally distributed, other than have a big number of respondents.
I was wondering if using more numbers e.g. rand(1,9) and then use 1-3, 4-6 and 7-9 to determine the group the respondent falls into would make a difference. I would need to wrap my head around this and study if it makes sense that this could have any impact. My stomach says yes, because each number has a smaller chance of being drawn next. But then the chance that it is one of the 3 numbers that determine the same group is als 33,33%. So I am not sure if this makes any difference.
But in any way, you need a bigger sample to get a more even distribution.
What you can do is adapt your relevance equations manually when you see that one bucket got filled more than another.
E.g. if the 1 gets more, just hide this question for a while and add the 1 to the other question which is shown for 2 (so for some time it will be shown for 1 AND 2). This is something you can use towards the end to fill up the "least filled bucket" to have a more or less even distribution.