Back to Blog
Technical Deep Dive
January 22, 20267 min read

How Random Wheel Algorithms Work: The Science Behind Fair Spins

Ever wondered what happens when you click "spin"? The answer involves randomness, physics simulation, and careful algorithm design.

A wheel spinner combines two separate systems: a random number generator that picks the winner, and a physics animation that shows the wheel slowing down. Understanding how these work together helps you evaluate whether a wheel is truly fair.

📚 New to wheel spinners? Check out our Complete Wheel Spinner Guide 2026 for everything you need to know.

The Two-Part System

Most people assume the wheel animation determines the winner—that the physics of the spin decides where it lands. In reality, well-designed wheel spinners work the opposite way:

Step 1: Pick Winner

The algorithm generates a random number to select the winning segment before the animation starts.

Step 2: Animate

The wheel animation is calculated to land on the pre-selected winner, creating suspense while ensuring fairness.

This "winner-first" approach is actually more fair than letting physics decide. Why? Because simulated physics can be influenced by factors like browser performance, frame rate, or timing—introducing unintended bias.

How the Random Selection Works

The fairness of a wheel spinner depends entirely on how it generates random numbers. There are three common approaches:

Math.random() — Not Ideal

JavaScript's basic random function is pseudo-random. It uses a mathematical formula that can theoretically be predicted. Fine for games, but not for high-stakes selections.

Server-Side Random — Trust Required

Some wheels send a request to a server that returns the winner. This can be secure, but you must trust the server isn't manipulating results. Learn more about client-side vs server-side randomness.

Web Crypto API — Gold Standard

Cryptographically secure randomness from your browser's built-in security features. Unpredictable, unbiased, and runs entirely on your device.

Inside the Algorithm

Here's a simplified view of how a fair wheel spinner algorithm works:

// 1. Get cryptographically secure random bytes
const randomBytes = crypto.getRandomValues(new Uint32Array(1));

// 2. Convert to a number between 0 and 1
const randomValue = randomBytes[0] / (0xFFFFFFFF + 1);

// 3. Select winner based on number of segments
const winnerIndex = Math.floor(randomValue * segments.length);

// 4. Calculate animation to land on winner
const targetAngle = calculateAngleForSegment(winnerIndex);
const totalRotation = (fullSpins * 360) + targetAngle;

// 5. Animate with easing for natural deceleration
animateWheel(totalRotation, duration, easeOutCubic);

The key insight: the winner is determined by crypto.getRandomValues() in step 1. Everything after that is just visual presentation.

The Physics Simulation

The animation that makes a wheel spinner feel "real" uses easing functions to simulate physical deceleration:

Initial Velocity

Fast spin at the start creates excitement

Deceleration Curve

Gradual slowdown mimics friction

Final Position

Lands precisely on pre-selected winner

Common easing functions include "ease-out-cubic" and "ease-out-quart" which create that satisfying slow-down effect. The total rotation is calculated to complete multiple full spins before landing on the target segment.

Red Flag: Animation-Based Selection

If a wheel spinner claims the "physics" determines the winner, be cautious. True physics simulation in browsers is inconsistent across devices. Legitimate tools select the winner first, then animate. Learn more about how wheels can be manipulated.

Equal Probability: Avoiding Bias

A fair algorithm must give each segment exactly equal probability. This is harder than it sounds due to "modulo bias":

The Modulo Bias Problem

If you have 7 segments and generate a random number from 0-255, using randomNumber % 7 creates bias. Numbers 0-3 have a slightly higher chance (37 possibilities each) than 4-6 (36 possibilities each).

The Solution: Rejection Sampling

Quality implementations use "rejection sampling"—if the random number would cause bias, they discard it and generate a new one. This ensures mathematically perfect equal probability.

How AllWheel Implements Fair Selection

Cryptographic Randomness

Uses Web Crypto API for unpredictable, secure random number generation

Client-Side Execution

All selection happens in your browser—no server can influence results

Bias Elimination

Rejection sampling ensures every segment has exactly equal probability

Transparent Code

Open browser dev tools to verify no network requests during selection

See Fair Algorithms in Action

Try our wheel spinner—built with cryptographic randomness and transparent selection.

Try Wheel Spinner →

Frequently Asked Questions

Does the wheel animation affect who wins?

In well-designed spinners, no. The winner is selected by the random number generator before the animation starts. The animation is calculated to land on the pre-selected winner.

Why not use real physics simulation?

Browser-based physics is inconsistent across devices and can be affected by CPU load, frame rate, and other factors. Pre-selecting the winner ensures consistent fairness regardless of device performance.

How can I verify a wheel is fair?

Check if it uses client-side selection (no network requests during spin), cryptographic randomness (Web Crypto API), and handles modulo bias. Read our guide on how to prove a giveaway was fair.

What is modulo bias?

A mathematical quirk where naive random number conversion gives some outcomes slightly higher probability than others. Quality tools use rejection sampling to eliminate this bias completely.

Related Posts