Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Bias in rand function for random number generation ?

More
1 year 5 months ago #258069 by holch
Joffm, I am not sure if I understand you correctly. But it seems that you are suggesting that if the random number generation is in a different question group it doesn't change when questions in later groups have conditions based on this random number.

But according to my small test, any condition calls the equation and this will have a new rolling of the dice as a result.

Not sure if I am wrong or if I am understanding you wrong.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

More
1 year 5 months ago #258072 by jelo

Again, contrarily to what Joffm said, I did not notice any switch in values when I call these variables in my image paths. Out of 63 responses, I conclude that it simply does not happen?
What do you mean by "not notice"? How do you check if the equation is executed again or not?
The golden standard is to fixate the random number via the "is_empty" function.

LimeSurvey is using PHP functions to create the random numbers. If there are issues it might be depending on your webstack and PHP version you use.
Seldom these days, but  I wouldn't rule that out.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: lea_crtl

Please Log in to join the conversation.

More
1 year 5 months ago - 1 year 5 months ago #258078 by lea_crtl
As you may have understood, I define the random variable in the beginning, in a given question group. Later, 10 groups are displayed only if the condition rand == 1 is verified, then similarly 10 groups call the condition rand == 2, then 10 groups again call the condition rand == 1, and finally 10 groups call the condition rand == 2. So in my survey, there are 40 condition calls on the random variable! If, as it was assumed, the value of the random variable changes everytime a condition is called, I should have observed in the database (since my survey is already launched, I just looked at the response table) cases where for the same respondent, question groups for rand == 1 AND rand == 2 appear. However this never happened. This is still unclear why the small test that holch conducted led to different results though.
Last edit: 1 year 5 months ago by lea_crtl. Reason: English mistake

Please Log in to join the conversation.

More
1 year 5 months ago #258086 by tpartner
As far as I know, the equations to generate the random numbers are only fired when their group is opened or submitted. The resulting random numbers should not be modified by accessing them later in the survey.

Having said that, yes, always good to use is_empty to lock them after the first assignment.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
1 year 5 months ago #258099 by holch

As far as I know, the equations to generate the random numbers are only fired when their group is opened or submitted. The resulting random numbers should not be modified by accessing them later in the survey.


Thanks for chiming in Tpartner. It is always good to have experienced LS users to contribute their knowledge.

However, my little test yesterday makes me believe otherwise. I will have to test this again. Maybe I made a mistake yesterday.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose