CCalculate.Studio

🎲 Random Number Generator

This generator draws random integers from a range you choose, optionally without repeats. It is seeded rather than clock-driven, which means the same seed always reproduces exactly the same draw — a property that matters for teaching, for reproducible research and for anyone who needs to show their working. Change the seed to draw again.

Cập nhật lần cuối: 2026-07-07100% miễn phí · Không cần đăng ký
Add as preferred on Google

What this generator is and is not suitable for

Pseudorandom generators differ enormously in what they are fit for. This one is fast, reproducible and statistically well behaved for everyday use, and it is emphatically not a source of secrets.

UseSuitable?Why
Teaching, simulations, samplingYesReproducible draws are an advantage
Picking a winner, dice, lottery numbersYes, with a fresh seedAnyone who knows the seed can reproduce the draw
Passwords, keys, tokens, session idsNoThe state is recoverable from the output; use the password generator instead
Regulated gaming or gamblingNoThose require certified hardware or cryptographic generators
  • Both ends of the range are inclusive, so a range of 1 to 100 contains 100 possible values.
  • Without replacement, the number of draws cannot exceed the number of values in the range. The calculator refuses rather than silently repeating.

What a pseudorandom generator is

A pseudorandom number generator is a deterministic algorithm that produces a sequence which passes statistical tests for randomness. It is not random in the physical sense: it is a fixed recurrence, and from a given starting value — the seed — it always produces the same sequence.

This one is a 32-bit xorshift generator, published by George Marsaglia in the Journal of Statistical Software in 2003. It works by repeatedly exclusive-oring a value with shifted copies of itself, using a shift triple chosen so the sequence visits every non-zero 32-bit state before repeating.

The seeding is deliberate rather than a limitation. Every calculator on this site is a pure function of its inputs, which is what makes results reproducible and checkable. It also gives you something a clock-driven generator cannot: quote the seed alongside your numbers and anyone can reproduce your draw exactly.

How to use the random number generator

  1. Set the smallest and largest values. Both ends are included in the range.
  2. Choose how many numbers to draw.
  3. Decide whether repeats are allowed. Without replacement, no value can appear twice, so you cannot draw more numbers than the range contains.
  4. Change the seed whenever you want a different draw. The same seed always returns the same numbers.

How the numbers are produced

x = x XOR (x << 13); x = x XOR (x >> 17); x = x XOR (x << 5)
u = x / 2^32, giving 0 <= u < 1
value = min + floor(u x (max - min + 1))
values in range = max - min + 1

The xorshift recurrence transforms a 32-bit state three times per draw, then divides by 2^32 to give a value in the interval from zero up to but not including one. Multiplying by the size of the range and taking the floor maps that to an integer.

Drawing without replacement uses a partial Fisher-Yates shuffle over the range. Each draw swaps one remaining element into place, which selects a uniformly random subset in a single pass and cannot stall the way a draw-and-retry approach does as the pool empties.

Common mistakes

  • Using a pseudorandom generator for anything secret. The sequence is fully determined by the seed.
  • Expecting new numbers without changing the seed. Reproducibility is the point; the seed is the control.
  • Assuming the upper bound is excluded. Both ends of the range are inclusive here.
  • Requesting more unique values than the range holds.
  • Reading a run of similar values as a fault. Clustering is a normal property of random sequences, and its absence would be more suspicious than its presence.

Câu hỏi thường gặp

Why does the same seed always give the same numbers?

Because a pseudorandom generator is a deterministic recurrence, and the seed is its starting state. This is a feature rather than a defect: quoting the seed lets anyone reproduce your draw exactly, which is what reproducible research and classroom demonstrations need. To draw differently, change the seed.

Is this random enough for a prize draw?

For an informal draw, yes, provided you choose a seed that participants cannot predict and publish it afterwards so the result can be verified. For regulated gaming, no — those settings require certified hardware generators or cryptographically secure algorithms.

Can I use this to generate a password?

No. The internal state of a xorshift generator can be recovered from a short run of its output, so anything derived from it is predictable. Use the password generator on this site instead, which draws from the operating system's cryptographically secure random source.

What does drawing without replacement mean?

It means no value can appear more than once, as when drawing lottery balls. Because each draw removes a value from the pool, you cannot draw more numbers than the range contains — drawing six unique values from a range of five is impossible.

Are the numbers uniformly distributed?

Yes, to the precision of the underlying generator. Each value in the range is equally likely, and the without-replacement mode uses a partial Fisher-Yates shuffle, which selects every subset of a given size with equal probability.

Tài liệu tham khảo

  1. Marsaglia G. Xorshift RNGs. Journal of Statistical Software 2003; 8(14): 1-6. doi:10.18637/jss.v008.i14.
  2. Knuth DE. The Art of Computer Programming, Volume 2: Seminumerical Algorithms, 3rd edition. Addison-Wesley, 1997 — random number generation and statistical testing.
  3. Fisher RA, Yates F. Statistical Tables for Biological, Agricultural and Medical Research. Oliver and Boyd, 1938 — the shuffle used for sampling without replacement.
  4. L'Ecuyer P, Simard R. TestU01: A C library for empirical testing of random number generators. ACM Transactions on Mathematical Software 2007; 33(4): 22.

Thống Kê · Tất cả máy tính

Máy tính liên quan