vtselios7
Member
- Joined
- Feb 17, 2023
- Messages
- 6
- Programming Experience
- Beginner
Hello, i hope iam posting this question in the right place.Please forgine me if not. I am using an online software for statistics (survey solutions designer) that can run code. I have the above code that works fine.
This code returns 3 variables in a questionnaire. The problem is that the probability of occurrence of each variable is not equal. I want the probability to be equal and also the occurrence to be unique. Each variable should only occur once.
Any help would be appreciated. Thanks in advance!
C#:
$q5rand
var r = Math.Log(1 + Math.Floor(Quest.IRnd()*1000000)/1000000);
var s = r.ToString("0.0000000000").Substring(3);
var items = new[]{"item1","item2","item3"};
for (var i = 0; i < items.Length; i++)
{
var n = Convert.ToInt32(s.Substring(i,1));
if (n >= items.Length) n = 0;
var t = items[I];
items[I] = items[n];
items[n] = t;
}
return items
(new Func<string>( () => {
$q5rand[0];
})).Invoke()
(new Func<string>( () => {
$q5rand[1];
})).Invoke()
(new Func<string>( () => {
$q5rand[2];
})).Invoke()[/I][/I]
This code returns 3 variables in a questionnaire. The problem is that the probability of occurrence of each variable is not equal. I want the probability to be equal and also the occurrence to be unique. Each variable should only occur once.
Any help would be appreciated. Thanks in advance!
Last edited by a moderator: