0

In the context of polls of voting results, I want to generate random numbers with specific properties to sample the possibilities within the margin of error of the poll.

For example, suppose I have polling results:

  • Party A: 34%
  • Party B: 25%
  • Party C: 14%
  • Party D: 27%

With a margin of error of 3.2% on the poll-results.

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.

I want each element of the batch to be smaller (in absolute value) than the given margin of error of the poll-results.

An example could be: (-0.5, +1.2, +0.1, -0.8). All the elements sum up to zero and each element is in absolute value smaller than 3.2, i.e. the given margin of error of the poll-results.

When generating a large amount of this kind of batches of random numbers, I would like these to have some specific statistic properties:

  • The maximum of the absolute values of the elements 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?

thomvil
  • 1
  • 1
  • You are not generating true random numbers. If a batch sums to zero, then the last number of the batch is fully determined by the values of the previous numbers in that batch and is not random at all. – rossum Jun 09 '21 at 08:06
  • @rossum this is obviously true, but a constraint of the context of the problem. It would not make sense to have voting percentages that don't add up to 100%. This is not a problem. – thomvil Jun 09 '21 at 09:42
  • You could generate random vectors of the form `(x, x, -x, -x), (x, -x, x, -x)` etc, where `x` is uniform on `[-3.2, 3.2]`. I am not sure if this is possible otherwise. – hilberts_drinking_problem Jun 09 '21 at 13:27
  • Note cross-post: https://stats.stackexchange.com/questions/529974/generate-batches-of-random-numbers-that-each-are-zero-sum-and-for-which-mean-of – Peter O. Jun 10 '21 at 10:15
  • `Obviously because voting is a zero-sum game, the numbers in the batch need to sum up to zero.` Huh?!? You need them to sum up to 1 (100%). – Severin Pappadeux Jun 10 '21 at 13:47
  • @SeverinPappadeux i want to generate a batch of "deviations" from the poll results. Like the example i gave of `(-0.5, +1.2, +0.1, -0.8)`. This adds up to zero, because if "applied" (added to) the poll-results of `(34, 25, 14, 27)` (= the polling results of the 4 parties), the resulting variation is `(33.5, 26.2, 14.1, 26.2)`. The seat allocation of this variation is than calculated. The goal is to repeat this for many variations, to estimate the expected variations in seat allocations – thomvil Jun 10 '21 at 15:02
  • @thomvil this is wrong approach. You have to sample population, you know a lot about population. You pretty much don't know anything about errors, your sampling would be G in -> G out style. – Severin Pappadeux Jun 10 '21 at 15:50

0 Answers0