In the context of polls of voting results, i want to generate random numbers with specific properties to sample the possibilities within the error of margin.
For example, suppose i have polling results:
- Party A: 34%
- Party B: 25%
- Party C: 16%
- Party D: 26% With a margin of error of 3.2%
I want to generate batches of 4 (because in this case there are 4 parties) random numbers. Obviously because voting is a zero-sum game, the numbers in the batch need to sum up to zero.
Given the error of margin, i want each element of the batch to be (in absolute value) less than that.
An example could be: (-0.5, +1.2, +0.1, -0.8)
When generating a large amount of these kind of batches of random numbers, i would like these to have some specific statistic properties:
- The maximum of the absolute value should be uniformly distributed over
(0, error_of_margin). (This is the easy part) - The mean of the absolute values should also be uniformly distributed over
(0, error_of_margin)
I tried two different approaches. I will link a gist, to not fill the question with code. https://gist.github.com/thomvil/02890ea2873eed6bb155e7dc387c9564
Does anybody have some suggestions on how i could tackle this?
Thank you
Aucun commentaire:
Enregistrer un commentaire