Draw system

Asked

Viewed 1,165 times

0

I am intending to make a draw system on my website. I read some questions (including one that I liked very much that was this one) and I noticed people saying that X Cities could never be drawn, while Y Cities drawn multiple times.

The question is: what is the reliability of the following lottery cases?

Draw by SQL

SELECT `id` FROM `tabela` ORDER BY RAND () LIMIT 1;

Draw by PHP

<php
$minimo = 0;
$maximo = 10000;
$sorteio = rand($minimo, $maximo);
echo $sorteio;
?>

I thought of some formulas to include the factor heaviness in my draw, but I realized it would be easier just to register the same item of the draw again.

In fact, the final question is: how to draw lots of people, assigning some of these advantages Example: John has a 60% chance of being chosen, Mary has a 40% chance) - It is better to put the name of John 6 times in the draw and the name of Mary 4 times or there is some solution defined?

  • I believe the problem is similar to this. See if the answer given by Inkeliz helps you.

  • I’ll take a look

  • In the [so] there is this reply also that can be useful.

1 answer

2

We have to understand some statistics to get the final question.

An experiment is considered random when its occurrences may present different results. An example of this is when we launch a coin that has different faces, one face and the other crown. The outcome of this launch is unpredictable, as there is no way of knowing which face will be up.

The sampling space (S) determines the possible outcomes. In the case of a coin toss the set of sample space is given by: S = {heads, tails}, because they are the only two possible answers to this random experiment.

In probability the occurrence of a fact or situation is called an event. Therefore, by flipping a coin we are establishing the occurrence of the event. We have therefore that any subset of the sample space should be considered an event. An example can happen when tossing a coin three times, is to get as a result of the event the following set:

E = {Heads, tails, heads}

The probability ratio is given by the possibilities of an event occurring taking into account its sampling space. This ratio which is a fraction is equal to the number of elements of the event (numerator) over the number of elements of the sample space (denominator). Considers the following elements:

E é um evento.
n(E) é o número de elementos do evento.
S é espaço amostral.
n(S) é a quantidade de elementos do espaço amostral.
A Razão de probabilidade é dada por:

         n(E)
  P(E)= -----     sendo n(S) ≠ 0
         n(S)

In relation to your question we would have:

 S = {João, João, João, João, João, João, Maria, Maria, Maria, Maria}
 S =10

In the case of João

 E = {João, João, João, João, João, João}
 E = 6

 P(João) = 6/10 = 60%

And in the case of Maria

 E = {Maria, Maria, Maria, Maria}
 E=4

 P(Maria) = 4/10 = 40%

The probability is usually represented by a fraction, whose value will always be between 0 and 1.

We can also represent probability with a decimal number or as a percentage

Therefore John will have 60% probability against 40% of Mary in a number of elements equal to 10.

If this number of elements are, for example, 1000, being 6 of John and 4 of Mary we would have:

P(John) = 6/1000 = 0,6%

P(Maria) = 4/1000 = 0,4%

  • When you are just looking for random content on the Stack and come across this class... hahaha

Browser other questions tagged

You are not signed in. Login or sign up in order to post.