UnipickerDraw Whitepaper
Draw Logic

Unipicker draw logic

See Unipicker's main draw logic.

Basic draw logic

Unipicker selects winners with the logic below.

  1. Obtain a "seed" from the "seed issuance server."Pass the "seed" as the input to the "random number generation algorithm."
  2. Assign a random number to each entrant.
  3. Sort entrants by their random number.
  4. For group draws, a random number is also assigned to the draw settings.A group draw means picking winners group by group. This type of draw requires draw-settings input that sets the number of winners per group info (rank or prize name, or apartment building/unit — anything that distinguishes winners). Unipicker assigns a random number not just to entrants but to the draw settings too.
  5. Sort the draw settings by their random number.
  6. Take the sorted entrants in order and assign (declare winners) them to the sorted draw settings.
* When sorting entrant (or draw-settings) info, sorting is based on each entrant's assigned random number — if the issued "seed" is odd, sort ascending; if even, sort descending. This keeps an entrant listed earlier in the input data from getting priority just because two or more entrants share the same random number.
<Figure 1> Building/unit winner draw — random-number assignment and winner selection example
Seed : 6829955767104992498
Assign a random number to each entrant
EntrantRandom
James0.2498216440435499
Michael0.5390021712519228
David0.4989048286806792
Chris0.881228075362742
Brian0.2693764951545745
Kevin0.3479937631636858
Steve0.7156692454591393
Assign a random number to each setting
Draw settingsRandom
101-1010.05107798264361918
101-5040.5512312969658524
103-5020.3550391604658216
105-7010.26768961385823786
105-9030.36229446344077587
Since the seed is even, sort descending by random number
Take the sorted entrants in order and assign them (win) to the sorted draw settings
Sorted entrant info
EntrantRandom
Chris0.881228075362742
Steve0.7156692454591393
Michael0.5390021712519228
David0.4989048286806792
Kevin0.3479937631636858
Brian0.2693764951545745
James0.2498216440435499
·
Winner
Lost
Lost
Sorted draw settings
Draw settingsRandom
101-5040.5512312969658524
105-9030.36229446344077587
103-5020.3550391604658216
105-7010.26768961385823786
101-1010.05107798264361918
Weighted draw logic

Unipicker's weighted draw has 2 methods: the weighted interval draw method and the weighted key draw method.

Apart from seed generation, the random numbers used in the weighted draw logic can be made using either the SHA-256(seed|N) method¹ or the xoshiro(seed) method².

1. Weighted interval draw method

Unipicker applies the weighted interval draw, one of its weighted draw methods, as follows.

  1. Shuffle the entrant list at random.Shuffle the entrant list at random using the Fisher-Yates shuffle algorithm³. Entrants are placed according to the shuffled order, and each entrant gets a winning interval sized in proportion to their weight.
  2. Shuffle the draw settings at random.Shuffle the draw settings at random using the Fisher-Yates shuffle algorithm³.
  3. Generate the "target value."(1) The "target value" ranges from 1 to the "total entrant weight." (2) Generate a random number within that range and use it as the "target value." e.g., if the "total entrant weight" is 600, the random-generation range is 1 to 600.
  4. Select the winner.Walk through the entrant list in order, and if the "target value" falls within a particular entrant's "winning interval," select that entrant as the winner.
  5. Assign the winner to the draw settings.Assign the selected winner, in order, to the shuffled draw settings. Repeat steps 3–6 until every draw-setting item has a winner assigned.
  6. Remove an entrant selected as a winner from the pool for subsequent rounds.Reset the winning intervals based on the remaining entrants, and recompute the total entrant weight. e.g., if the weight total was 600 and the winner's weight was 160, the next range is 1 to 440.
<Figure 2> Weighted interval draw — winner selection example
Shuffle the entrant list with Fisher–Yates
Entrant list (before shuffle)
EntrantWeight (W)
Charlie150
Naomi50
Kevin10
Olivia200
Steve160
Andrew100
Brian30
Fisher–Yates
shuffle
Entrant list (after shuffle)
EntrantWeight (W)
Andrew100
Olivia200
Charlie150
Naomi50
Brian30
Kevin10
Steve160
Fisher–Yates shuffle — shuffle starts from the last seat.
Swap the last (7th) seat's entrant with the entrant in a seat randomly drawn from 1–7 — here, the 5th seat (Brian ↔ Steve)
Swap the seat before that (6th) with a seat randomly drawn from 1–6 — here, the 3rd seat (Andrew ↔ Kevin)
Shuffle the draw settings with Fisher–Yates
Draw settings (before shuffle)
Draw settings
Rank 1
Rank 2
Rank 3
Fisher–Yates
shuffle
Draw settings (after shuffle)
Draw settings
Rank 2
Rank 1
Rank 3
Fisher–Yates shuffle — shuffle starts from the last setting.
Swap the last (3rd) setting with the setting in a seat randomly drawn from 1–3 — here, the 3rd seat (same seat, so no swap)
Swap the one before that (2nd) with a seat randomly drawn from 1–2 — here, the 1st seat
Determine the "target value"
Random-generation range
1 to 700
Total entrant weight
Generate target value
random number
Generated "target value"
412
Select the winner
Andrew100
Olivia200
Charlie150
Naomi50
1
101
301
451
501 ~ 700
Target value 412
EntrantWeightWinning interval
Andrew1001 ~ 100
Olivia200101 ~ 300
Winner selectedCharlie150301 ~ 450 412 target value
Naomi50451 ~ 500
Steve160541 ~ 700
Assign the winner to the draw settings (win)
Selected winners
1st
Charlie
2nd
Steve
3rd
Naomi
Assign (win)
Draw settings
Rank 2
Rank 1
Rank 3
Remove the winner from the next round
Andrew100
Olivia200
Naomi50
1
101
301
351 ~ 550

After removing Charlie, the weight total changes 700 → 550, and the remaining entrants' winning intervals are recomputed.

¹ SHA-256(seed|N) method — generates each random number independently using the SHA-256 hash function. Suited to draws that place weight on reproducibility and verifiability.
² xoshiro(seed) method — generates a continuous stream of random numbers based on the seed value. Fast to process, suited to large-scale draws.
³ Fisher-Yates shuffle algorithm — used to randomly arrange the entrant list. It is an unbiased shuffle algorithm that guarantees every possible permutation is generated with equal probability, and is widely used in statistics and computer science.
menu_bookReferences
2. Weighted key draw method

Unipicker applies the weighted key draw, one of its weighted draw methods, as follows.

  1. Assign a random number to each entrant.Issue every entrant one random number (u) between 0 and 1.
  2. Generate a Key value that reflects each entrant's weight.Compute each entrant's Key value from the issued random number (u) and their weight (w). A bigger weight makes a smaller Key more likely, and win priority is set in ascending order of Key value.
  3. Sort the entrant list ascending by the computed Key value.
  4. Shuffle the draw settings at random.Shuffle the draw settings at random using the Fisher-Yates shuffle algorithm¹.
  5. Assign the entrants, sorted by Key value, in order to the shuffled draw settings (winners).
key = −ln(u) / wu: a random number between 0 and 1 · w: the entrant's weight · −ln(u) turns the random number into a value suited to applying weight, implementing a win probability proportional to weight.
※ Based on the weighted sampling algorithm proposed by Efraimidis–Spirakis (2006).
<Figure 3> Weighted key draw — winner selection example
Assign a random number to each entrant and compute each one's Key value
EntrantWeight (W)Random (U)−ln(u)key=−ln(u)/w
Charlie1500.730.31470.002098
Naomi500.410.89160.017832
Kevin100.950.05130.005129
Olivia2000.122.12030.010601
Steve1600.530.63490.003968
Andrew1000.750.28770.002877
Brian300.440.82100.027366
Sort the entrant list ascending by the computed Key value
OrderEntrantWeight (W)Random (U)−ln(u)key=−ln(u)/w
1Charlie1500.730.31470.002098
2Andrew1000.750.28770.002877
3Steve1600.530.63490.003968
4Kevin100.950.05130.005129
5Olivia2000.122.12030.010601
6Naomi500.410.89160.017832
7Brian300.440.82100.027366
Shuffle the draw settings with Fisher–Yates
Draw settings (before shuffle)
Draw settings
Rank 1
Rank 2
Rank 3
Fisher–Yates
shuffle
Draw settings (after shuffle)
Draw settings
Rank 2
Rank 1
Rank 3
Fisher–Yates shuffle — shuffle starts from the last setting.
Swap the last (3rd) setting with the setting in a seat randomly drawn from 1–3 — here, the 3rd seat (same seat, so no swap)
Swap the one before that (2nd) with a seat randomly drawn from 1–2 — here, the 1st seat
Assign winners to the shuffled draw settings in order of Key value
OrderEntrantWeight (W)keyDraw settings (after shuffle)Result
1Charlie1500.002098Rank 2Winner
2Andrew1000.002877Rank 1Winner
3Steve1600.003968Rank 3Winner
4Kevin100.005129Lost
5Olivia2000.010601Lost
6Naomi500.017832Lost
7Brian300.027366Lost
menu_bookReferences
  • Efraimidis, P. S., & Spirakis, P. G. (2006). Weighted Random Sampling with a Reservoir. Information Processing Letters, 97(5), 181–185.
Ball-number public draw logic

This draw determines the draw random number from the Unipicker random seed and a ball number drawn on-site.
A draw participant or organizer can join the draw in person for even greater fairness.
Fairness can only be guaranteed, however, when the whole process is disclosed live in real time.

Unipicker-generated random number
2498753211
×
Ball number drawn on-site
4
1
3
9
=
Last 8 digits of the result = draw random number
10342339540329

Entrant's draw random number = 39540329

Unipicker applies the ball-number public draw logic below.

  1. Assign each entrant a random number generated by Unipicker.After stripping the generated random number down to its decimal digits, assign its first 10 digits (the Unipicker random number).
  2. Multiply the entrant's Unipicker random number by the ball number.Use the ball number drawn publicly on-site.
  3. Sort entrants by the last 8 digits of the product.
  4. Process the sorted entrants as winners in order.
* When sorting entrant info, sorting is based on each entrant's assigned winning random number — if the entered ball number is "odd," sort "ascending"; if "even," sort "descending." This keeps an entrant listed earlier in the input data from getting priority just because two or more entrants share the same random number.
* Unlike other draws, the ball-number public draw does not shuffle the draw settings at random. This policy decides winners strictly by the sort order of the transparently disclosed entrant random numbers.
Mass-entrant winner draw logic

Unipicker's basic draw logic assigns a random number to each entrant to pick winners. But PC CPU and memory limits make it unsuited to mass draws.
A mass draw assigns each entrant an entry number in order and uses a computer random number to draw winning numbers.
To draw fair random numbers it applies "1. the unfair-number rejection policy," and to efficiently check for duplicate winning numbers it uses "2. Floyd's Sampling Without Replacement."

<Figure 4> Mass-entrant winner draw — draw info example
(1) Assume the computer's random numbers are fixed to the 12 numbers from 1 to 12.
(2) Total entrants: 5
Entry numberEntrant
No. 1James
No. 2Daniel
No. 3Ryan
No. 4Tom
No. 5Mark
※ This example assumes a 1–12 random-number range to make the draw logic easy to understand.
In practice, Unipicker can generate random numbers up to 9,007,199,254,740,992 (2⁵³).
1. Unfair-number rejection policy

Using <Figure 4>'s assumptions to draw a computer random number and decide 1 winner, the winning numbers can generally be laid out by computer random number as below.

Fair random-number range (only multiples of the entrant count are used)Unfair
rejected
Random No.123456789101112
Winning no.
(winner)
No. 1
James
No. 2
Daniel
No. 3
Ryan
No. 4
Tom
No. 5
Mark
No. 1
James
No. 2
Daniel
No. 3
Ryan
No. 4
Tom
No. 5
Mark
No. 1
James
No. 2
Daniel

e.g., if the generated random number is 4, No. 4 Tom is selected; if 8, No. 3 Ryan is selected as the winner.

As above, if the computer's generated random-number range (1–12) is used as is, a random number of 11 or 12 gives James and Daniel a higher win probability than everyone else.

※ Win chances per entrant
Entry numberEntrantWin chances
No. 1James3× (1, 6, 11)
No. 2Daniel3× (2, 7, 12)
No. 3Ryan2× (3, 8)
No. 4Tom2× (4, 9)
No. 5Mark2× (5, 10)
Unfair
rejected
Entry numberEntrantFinal chances
No. 1James2× (1, 6, 11)
No. 2Daniel2× (2, 7, 12)
No. 3Ryan2× (3, 8)
No. 4Tom2× (4, 9)
No. 5Mark2× (5, 10)
Equal win chances for all, via the "unfair-number rejection policy"If the random-number range (1–12) is used as is, James and Daniel get a higher win probability than others whenever 11 or 12 comes up. Apply the unfair-number rejection policy and Nos. 1–3 get 3 chances (1·6·11 / 2·7·12) while Nos. 4–5 get 2 chances (4·9 / 5·10) — everyone has the same win chances within the valid range (1–10).

If the computer random number generated for a fair probability comes up 11 or 12, it is discarded and a new computer random number is generated instead.
In other words, a valid computer random number only uses the range that is a multiple of the entrant count; anything beyond that is rejected.
This is called the "unfair-number rejection policy."

※ The formula matching each computer random number to a winning number is as follows.
Winning number = computer random number % entrant count
( the remainder of the computer random number divided by the entrant count )
※ This example is written to make the draw logic easy to understand.
The actual formula is winning number = (computer random number % entrant count) + 1; 1 is added so winning numbers start from 1.
2. Floyd's Sampling Without Replacement

To keep winning numbers from repeating, every draw must be checked against existing winning numbers for duplicates. If the number of winners needed is very large or duplicates occur often, this check can repeat excessively — so mass-entrant winner draws apply Floyd's Sampling Without Replacement.

Using <Figure 4>'s assumptions to draw computer random numbers and decide a total of 3 winners, duplicate draws can be prevented as below.

<Figure 5> Mass-entrant multiple-winner draw example
※ Entrant list per draw round
1st draw range
2nd draw range
3rd draw range
No. 1
James
No. 2
Daniel
No. 3
Ryan
+
No. 4
Tom
+
No. 5
Mark
※ Entry-number range and result per draw round
DrawEntry-number rangeResultWinning-number list
(1) 1st1 ~ 3Computer random number 11 → No. 2No. 2
(2) 2nd (duplicate occurs)1 ~ 4Computer random number 2 → No. 2 (duplicate) → newly added No. 4 winsNo. 2, No. 4
(3) 3rd1 ~ 5Computer random number 6 → No. 1No. 2, No. 4, No. 1

1st draw range = total entrants − total winners + 1 (=3); the range grows by 1 with each subsequent draw.

This logic is efficient because it never needs to regenerate a computer random number even when a duplicate comes up.
Entrants No. 1–3 get 3 draw chances, No. 4 gets 2, and No. 5 gets just 1 — which may look unfair. But if a duplicate winner turns up on the 2nd draw, No. 4 is selected as the winning number, and on the 3rd draw the existing numbers are likely to repeat, raising No. 5's chance of winning — so applying this logic effectively and fairly prevents duplicate draws.

It is an "algorithm designed so that, overall, everyone ends up with the same win probability — because earlier entrants get chances sooner but also risk being bumped, while later entrants join later but have a good chance of bumping someone out."
menu_bookReferences
Mass-entrant order draw logic

After winners are selected by the mass-entrant winner draw logic, the last winner's computer random number is used as the seed to assign each winner a new random number and set their order in the draw.

Running the order assignment with <Figure 5>'s assumptions gives the following.
Assume the initial "seed" value issued by Unipicker's "seed issuance server" is 161925012407392416.

Assign a random number to each winner
Winner infoRandom
No. 2
Daniel
0.677889
No. 4
Tom
0.321264
No. 1
James
0.473173
Random sort
Order-assignment result
OrderRandomWinner info
10.677889No. 2
Daniel
20.473173No. 1
James
30.321264No. 4
Tom
Random sort
Since the seed is even, sort descending by random number
※ If the seed is odd, sort ascending