S
S
Sergey2015-04-09 12:08:38
PHP
Sergey, 2015-04-09 12:08:38

What is the formula for counting votes?

There is a four-choice poll where the user can vote, 1 vote = 100%.
If the poll allows you to select only one answer (radio button), then the votes are distributed as follows:
1) 0
2) 100
3) 0
4) 0
If the poll allows you to select multiple answers (checkboxes), then the votes are distributed as follows:
1) 50
2) 0
3 ) 50
4) 0
And the last type of survey, where you need to sort the answer options in priority order, the result should be something like this: 1
) 70.83
2) 20.83
3) 8.33
4) 0
calculate these values?
An example of a survey where you need to sort the answer options in priority order:
Which color do you like better?:
1) Red
2) Blue
3) Green
4) Black

The user sets priorities (sorts), for example:
1) Blue
2) Black
3) Green
4) Red
And I need to save the result of this survey to the database. From the result, it can be seen that "Blue" for the user has the highest priority, "Black" is slightly lower, "Green" is even lower, and he does not like "Red" at all.
The question is how can I distribute his vote (100%) among these options, what formula should I use to calculate it?
X1>X2>X3>X4=100

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
localghost, 2015-04-09
@frost18

Sergei Kapirusov , now it's clearer.
But there is no general formula here, you yourself have to decide how to distribute the votes, how much "weight" to give to which position. That is: how much more "worth" the first place in comparison with the second, the second - with the third, and so on.
For example, you might decide that the "distance" between places should be the same, say five answer choices would be 40-30-20-10-0. Then this is an arithmetic progression, and (n * (n + 1)) / 2 * distance = sum, i.e. 100% (n is the number of non-zero answer options).
But this is not the only option, no one forbids you to do, say, 60-25-10-5 in the same case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question