Randomizations and probability calculations

Dear Kobo team,

I’d like to see if there is a way to be able to use a formula which can:

  1. Randomly choose an option amongst 3 options with an equal probability of 1/3 to be selected

  2. Calculating a winning and loosing decisiob based on (1 draws, 1 as probability of winning loosing, chance as a percentage) for example binomial (1,1, 0.5)

Your help is appriciated

@myriamdagher1, maybe this post discussed previously should give you some clue to your query:

Thank you Kal. Can you please share the image? I am not able to find it in your reply.

Please can you share the image you reffered to?

random testing.xlsx (17.9 KB)
I created the attached sheet and I appreciate your feedback on the below:

  1. Does the following expression: int(random() * 3) + 1 randomly choose between three options/groups (1, 2, 3) with equal probability for each option to be selected (1/3 probability for each)?
  2. Does this expression if(random() <= 0.5, ‘Win’, ‘Loss’) calculate the winning/losing based on 1 drawing, same probability for winning and losing, and a specific chance?


Hint: random() as any calculation will be activated/updated any time you open/edit the case. Otherwise, you would need to pack the calculation with once(…).

If you want to simply randomize choices you can use the randomize=true appearance for the select. See (Question Types - ODK Docs).

Don’t forget, please, to always check your form with the Online validator,, during development and before deployment. It will for ex. show you that you should add the 2-letter language codes in the columns. See
Adding Another Language to your XLSForm — KoboToolbox documentation.

1 Like

I copied your redundant new posting here. You can delete it there. Please, avoid posting for the same issue in more than one thread.

1 Like

Duplicate posting on the same issue, see https://community.kobotoolbox.org/t/randomizations-and-probability-calculations/47137. Please, keep in one main thread, also for following aspects on the same topic. You can edit your posts (pencil icon) or add new postings there to enhance/change your thread.

Thank you so much I used once(…) and the value generated did not change after loading the form!

Please, also see here, to remove your duplicate posting: https://community.kobotoolbox.org/t/randomization-and-probability-calculation/47277/3..

Hello Kobo team,

I’m seeking a formula to randomly select among 3 options with equal 1/3 probabilities. Additionally, I aim to calculate outcomes based on a binomial model (1 draw, 1 win/loss probability) like binomial (1, 1, 0.5). Any guidance on achieving this would be greatly appreciated. Thank you.