Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision |
en:create:functions:random [10.04.2016 10:20] – [random()] admin | en:create:functions:random [10.04.2016 10:20] – [Drawing with Replacement] admin |
---|
The PHP functions ''[[:en:create:functions:random|random()]]'' and ''[[:en:create:functions:random_p|random_p()]]'' (for weighted random draws) randomly draw with replacement. An unrestricted random draw "with replacement" is comparable to throwing a die. As a rule, group sizes vary greatly here and this can be problematic for the analysis. | The PHP functions ''[[:en:create:functions:random|random()]]'' and ''[[:en:create:functions:random_p|random_p()]]'' (for weighted random draws) randomly draw with replacement. An unrestricted random draw "with replacement" is comparable to throwing a die. As a rule, group sizes vary greatly here and this can be problematic for the analysis. |
| |
**Note:** When drawing with replacement, it is crucial to ensure that the random number is saved in the data record. To do this, use an [[:en:create:questions:internal|internal variable]] and the function ''[[:de:create:functions:put|put()]]''. | **Note:** When drawing with replacement, it is crucial to ensure that the random number is saved in the data record. To do this, use an [[:en:create:questions:internal|internal variable]] and the function ''[[:en:create:functions:put|put()]]''. |
| |
- Add a new question in the **List of Questions** using the type "Internal Variables" (e.g. with ID ''IV01'') | - Add a new question in the **List of Questions** using the type "Internal Variables" (e.g. with ID ''IV01'') |
- Add a variable (item) in this question with the description, as an example, "random number". According to the **Variables List**, this variable's ID is ''IV01_01''. | - Add a variable (item) in this question with the description, as an example, "random number". According to the **Variables List**, this variable's ID is ''IV01_01''. |
- [[php|PHP code]] is used to carry out the actual random draw. | - [[:en:create:php|PHP code]] is used to carry out the actual random draw. |
| |
<code php> | <code php> |