站点介绍

Our office party raffle broke in the most predictable way: the tool on the big screen could only produce one number at a time, so the poor host had to click three times for the three third-prize winners while everyone waited. I went home and built the version she actually needed - one that draws everything in a single click, and quietly fixes the biases nobody notices until they matter.
Most online RNG cores are Math.random modulo the range: take a pseudo-random float, multiply by the span, floor it. Two problems. The generator's seed is predictable. And the modulo introduces modulo bias: when 2^32 doesn't divide evenly by your span, the numbers in the remainder slice come up slightly more often - and in a giveaway, "slightly" is exactly where fairness cracks.
The fix here is rejection sampling: compute how many whole buckets your span divides into, and throw away any random value landing in the uneven tail, redrawing until it lands clean. The cost is a few extra random draws; the payoff is strictly equal probability for every number. Day to day you cannot tell the difference. At the grand prize draw, that difference is the whole story.
Lottery picks: the link ?min=1&max=49&n=6&uniq=1&sort=asc is a complete lotto setup - one click, six unique numbers in ascending order. Office raffle: big-number mode, staff ID range in, spacebar once per winner. Survey sampling: 1 to 5000, draw 50, unique and sorted, copy, done. Mock data: 6 decimal places, a thousand values, download the .txt and feed it to your program.
The most common raffle dispute is "the range was 1 to 200 last time, I'm sure of it." Keeping the last 10 draws locally - parameters plus result summaries with mean and min/max - settles that argument in one glance. It stops at 10 because this is not a ledger: for disputes that matter, you should have recorded your screen at the time, and browser storage will not win you a lawsuit. The FAQ says this out loud too.
The randomness itself is up to the job: a crypto-grade random source plus rejection sampling gives every number exactly equal odds, which is more than fair enough for office parties, classroom draws, and community giveaways. What it does not have is third-party notarization - the page runs locally in your browser, so there is no way to prove to a notary that nobody touched the settings at the moment of the draw. For public commercial giveaways, record your screen (range, count, and the click itself) as evidence; for anything with legal stakes, use a notarized or regulator-approved drawing service.
Math.random() is a predictable pseudo-random generator - fine for jitter animations, wrong for raffles. Worse, taking Math.random() modulo a range introduces modulo bias: when the range does not divide evenly into the generator's output space, some numbers come up slightly more often than others. This tool uses crypto.getRandomValues (the browser's crypto-grade source) with rejection sampling: random values that fall in the uneven tail are thrown away and redrawn, so every number has exactly equal probability. You will not notice the difference day to day, but in a giveaway that difference is the whole fairness story.
Yes. Pick 0 to 6 decimal places: 0 means integers, 2 fits money amounts, 6 works for mock datasets. The generator draws uniformly in the integer domain first, then scales down by a power of ten - so decimals are just as uniform across the range as integers, not integers with random digits glued on.
Unique draws require the range to hold at least as many values as you asked for: 1 to 10 contains only 10 integers, so 11 unique picks is mathematically impossible. The tool checks this up front and tells you to widen the range or lower the count - it never quietly hands you duplicates. With decimals, capacity scales by 10^places (1 to 10 at 2 decimals offers 901 distinct values).
In your browser's localStorage on this device - never uploaded. Only the last 10 draws are kept, older ones get pushed out automatically, and parameters plus result summaries typically stay under 20KB total. Switch devices or clear site data and it is gone; the Clear my data link in the footer wipes it in one click, and in private browsing it vanishes when the window closes.
Yes. Both bounds accept negatives - type or paste the minus sign like any other character. The tool works from the span (-10 to 10 spans 21 integers). For the [-1, 1) style ranges common in simulations, enter -1 to 0 as a close approximation.
中文版:https://www.9314.cn/tools/random-number/
评论列表 (0条)