Welcome to the LimeSurvey Community Forum

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

How to generate two or more unique random variables?

  • DVP17lemon
  • DVP17lemon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago #169245 by DVP17lemon
Hello, I want to generate two unique (var1 != var2) variables.

Now I have created two questions for these two variables, with the following Logic-Equations:


[RANDOM]:

{if(RANDOM>=1,RANDOM,rand(1,140))}

[RANDOMTWO]:

{if(RANDOMTWO>=1,RANDOMTWO,
if(RANDOM == 1, rand(2,140),
if(RANDOM == 140, rand(1,139),
if(rand(1,2) == 1, rand(1,(RANDOM-1)), rand((RANDOM+1),140)))))}


However, I will come into trouble, if I want to make more unique random variables.

Therefore, my question is:
Is there another way to generate unique random variables?
The topic has been locked.
  • DVP17lemon
  • DVP17lemon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 10 months ago - 5 years 10 months ago #169995 by DVP17lemon
ATTENTION! The code above does not give complete random variables, but a slightly skewed distribution of random variables.

However, I have found a better solution to create two unique random variables:

1) Create three random variables (questions of the type equation), e.g. RANDOM, RANDOMTWO, RANDOMINT in this order.
2) RANDOM gets the equation:
Code:
{if(RANDOM>=1,RANDOM,rand(1,2))}
3) RANDOMTWO gets the equation:
Code:
{if(RANDOMTWO >=1, RANDOMTWO, rand(1,2))}
4) RANDOMINT gets the equation:
Code:
{RANDOMTWO=(if(RANDOMTWO==RANDOM, rand(1,2), RANDOMTWO))}
--- to increase uniqueness you simply repeat this formula in the equation like this:
Code:
{RANDOMTWO=(if(RANDOMTWO==RANDOM, rand(1,2), RANDOMTWO))} {RANDOMTWO=(if(RANDOMTWO==RANDOM, rand(1,2), RANDOMTWO))} {RANDOMTWO=(if(RANDOMTWO==RANDOM, rand(1,2), RANDOMTWO))} {RANDOMTWO=(if(RANDOMTWO==RANDOM, rand(1,2), RANDOMTWO))}
Last edit: 5 years 10 months ago by DVP17lemon.
The topic has been locked.
More
5 years 10 months ago #170026 by mado88
Hi,
This comes close to my problem: A complex survey structure with multiple randomizations within one project. I will try to decribe it. Basically, I would like to run three experiments within one survey.
- Experiment 1 requires random assignment to three groups (A,B,C) (I understand how this works in general)
- Experiment 2 splits each of the three groups in 2 subgroups (i.e. Respondents first assigned to group A will randomly be assigned into group A.1 or A2 for the second question, original group B -> B.1, B.2, original group C-> C.1, C.2)
- Experiment 3 requires a new round of random assignment into 6 groups (U, V, W, X, Y, Z). The former group assignments should not influence this procedure.
- The survey should also have a general part, which everyone answers

I know that it is quite complicated, but do you think it is possible at all with Limesurvey? Thanks a lot!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 10 months ago #170030 by holch
I don't think that it is too complicated, because you actually only have to run 2 random assignments from what I see.
First random assignment generates a number from 1-6.
1 = A1
2 = A2
3 = B1
4 = B2
5 = C1
6 = C2
First assignment: Just show the A questions for those that received 1 and 2, B questions to those that received 3 and 4, etc.
Second assignment: Se above.
3rd assignment: just generate a new random number in a different equation question like before.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose