- Posts: 9
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
5 years 10 months ago #169245
by DVP17lemon
How to generate two or more unique random variables? was created 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?
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
5 years 10 months ago - 5 years 10 months ago #169995
by DVP17lemon
Replied by DVP17lemon on topic How to generate two or more unique random variables?
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:
3) RANDOMTWO gets the equation:
4) RANDOMINT gets the equation:
--- to increase uniqueness you simply repeat this formula in the equation like this:
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))}
Code:
{if(RANDOMTWO >=1, RANDOMTWO, rand(1,2))}
Code:
{RANDOMTWO=(if(RANDOMTWO==RANDOM, rand(1,2), RANDOMTWO))}
Last edit: 5 years 10 months ago by DVP17lemon.
The topic has been locked.
- mado88
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 10 months ago #170026
by mado88
Replied by mado88 on topic How to generate two or more unique random variables?
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!
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11637
- Thank you received: 2737
5 years 10 months ago #170030
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic How to generate two or more unique random variables?
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.
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.