PlayTools

Random draws: fairness, uniqueness, and cryptographic vs PRNG

任意の範囲で整数または小数の乱数を一括生成。重複なしモードにも対応。

Runs in your browser — nothing you enter is uploaded

Random draws: fairness, uniqueness, and cryptographic vs PRNG

Use crypto-backed draws when assigning prizes or secrets. PRNG modes are fine for simulations. “Unique numbers only” prevents duplicate raffle tickets within one batch.

Audit compliance may require external attestation—this page is a convenience utility.

How the numbers are generated

Each number comes from your browser’s cryptographically secure generator (crypto.getRandomValues), the same source used to create encryption keys. It is unpredictable even to someone who has seen every earlier result, and it is never seeded from the clock.

Turning random bits into a number in your range is where many generators go subtly wrong. Taking a 32-bit random value modulo the range size makes low numbers slightly more likely whenever the range does not divide 2³² evenly. This tool uses rejection sampling instead: draws that would fall into that uneven tail are discarded and redrawn, so every integer between your minimum and maximum has exactly the same probability. Ranges wider than 2³² combine two draws into a 53-bit value, the largest whole number JavaScript represents exactly.

Results are whole numbers. If you type decimal bounds they are rounded inward — a range of 1.5 to 9.9 draws from 2 to 9 — so the result can never fall outside what you entered.

Duplicates allowed vs unique numbers only

With duplicates allowed, every draw is independent, like rolling a die several times — repeats are expected and are not a sign of a broken generator. Repeats arrive sooner than most people expect: drawing 10 numbers from 1–100 has a 37% chance of at least one repeat, and drawing 23 numbers from 1–365 crosses 50% (the classic “birthday problem”).

With “unique numbers only” ticked, the tool draws without replacement, like pulling tickets from a hat. For ranges up to 100,000 it shuffles the whole range with a Fisher–Yates shuffle and takes the first N values; for larger ranges it draws and skips any value it has already picked. Either way, the order of the results is itself random.

Worked examples

  • Dice: 1 to 6 for a standard die, 1 to 20 for a d20. Set “how many” to the number of dice and leave duplicates allowed — two dice can show the same face.
  • Raffle with 250 numbered tickets and 3 prizes: minimum 1, maximum 250, generate 3, unique only. Draw all prizes in one click so no ticket can win twice.
  • Lottery-style pick (6 from 49): minimum 1, maximum 49, generate 6, unique only, then sort the numbers yourself if you want them in order.
  • Random spreadsheet row: if your data starts on row 2 and ends on row 1,001, use 2 to 1,001 so the header row can never be chosen.
  • Splitting 30 people into teams: number everyone 1–30, generate 30 unique numbers, and assign the first 10 results to team A, the next 10 to team B, and so on.

Running a fair public draw

The generator is fair, but a draw also has to be seen to be fair. Agree the range and the number of winners before drawing, run the draw once on screen or on a recorded call, and do not redraw because of an unwelcome result. Publish the settings (range, count, unique or not) alongside the winning numbers.

The tool keeps no log and stores nothing, which protects privacy but means it cannot later prove what was drawn. Sweepstakes and promotions governed by law in some countries require an independently audited draw; use a regulated provider for those.

Limits

  • Up to 1,000 numbers per click.
  • Bounds can be any whole numbers within about ±9 quadrillion (±2⁵³ − 1).
  • In unique mode, “how many” cannot exceed the size of the range — you cannot pick 11 distinct numbers from 1–10.

These free tools pair well with this page — open them in a new tab to finish your workflow.

よくある質問

本当にランダムですか?

このツールはブラウザの暗号学的に安全な乱数生成器window.crypto.getRandomValues()を使用しています。宝くじ番号・ランダムキー・ノンスの生成などセキュリティが重要な用途に適しています。Math.random() と異なり、過去の出力から次の値を予測することはできません。

PRNGとCSPRNGの違いは何ですか?

PRNG(擬似乱数生成器)はシードで初期化された決定論的アルゴリズムを使用します。同じシードからは同じ数列が生成されます。CSPRNG(暗号学的に安全なPRNG)は過去の出力がわかっても予測不可能です。このツールはCSPRNGを使用しています。

同じ数が2回生成されることはありますか?

はい。各数は等確率で独立して抽出されるため、一意性は保証されません。一意の数が必要な場合は、まとめて生成して重複を除去するか、シャッフル/順列アプローチを使用してください。

使用できる最大範囲はどのくらいですか?

JavaScriptの安全な整数範囲内の整数(最大2^53 - 1)をサポートしています。範囲内のすべての値が等確率です。剰余による偏りを避けるため棄却サンプリングを使い、2^32 を超える範囲では 32 ビットの乱数を 2 つ組み合わせます。

ダイスロールをシミュレートするには?

標準6面ダイスには1〜6の範囲を設定します。その他のダイス:d4は1〜4、d8は1〜8、d10は1〜10、d12は1〜12、d20は1〜20(テーブルトップRPGでよく使われる)。