Skip to content
AZ Tools

Random Distribution Generator

Generate samples from uniform, normal, exponential, Poisson, Bernoulli, or triangular distributions — with histogram, summary stats, and CSV/JSON export.

How to use

  1. Pick a distribution and adjust its parameters.
  2. Set the sample count (up to 5,000) and decimals.
  3. Click Generate to produce the samples — the histogram and stats update live.
  4. Copy as CSV, JSON, or newline-separated lines.

About this tool

Show

Draw up to 5,000 samples from six common distributions — uniform, normal, exponential, Poisson, Bernoulli and triangular — each with its own parameters, and see the result as a histogram alongside the mean, standard deviation, minimum, maximum and median. Useful for teaching, for seeding a simulation, for sanity-checking an A/B test, or for generating test data with a realistic shape rather than a uniform one.

The samplers are the standard constructions. Normal values come from the Box-Muller transform, which turns two uniform draws into two independent normal ones through a square root and a cosine. Exponential uses inverse transform sampling — the negative logarithm of a uniform, divided by the rate. Poisson is exact for rates below 30, using Knuth's method of multiplying uniforms until the product falls below e^−λ, and switches above that to a rounded normal approximation, because the exact method costs one uniform draw per unit of λ and would grind at large rates. The approximation is excellent in the body and slightly wrong in the tails, which is the trade every library makes at the same place.

Randomness comes from crypto.getRandomValues rather than Math.random, though the reason is narrower than it is usually stated. For a histogram, the browser's built-in generator is statistically fine — it passes the standard test batteries and you would not detect the difference in 5,000 samples. What the cryptographic source buys is unpredictability, which matters if the output seeds something an adversary should not be able to guess, and costs nothing here.

Five thousand samples is a small number for anything in the tails. The mean of that many normal draws has a standard error of about 0.014σ, so the figure shown will wobble in the second decimal place between runs, and that is the sampling working correctly rather than a bug. Bin count changes the apparent shape too: too few bins hide a bimodal distribution, too many turn a smooth one into noise. Move it before concluding anything about a shape you were not expecting.

Frequently asked questions

How are samples generated?

All uniform [0, 1) randomness comes from crypto.getRandomValues(Uint32Array), normalized to a double in [0, 1). Normal uses Box-Muller; exponential uses inverse CDF (-ln U / λ); Poisson uses Knuth's algorithm for λ < 30 and a normal approximation above; Bernoulli is a single comparison; triangular uses the inverse-CDF formula.

Is this cryptographically secure?

The underlying crypto.getRandomValues is — but the transformations (e.g., Box-Muller) preserve only statistical quality, not cryptographic guarantees. Use this for simulations and stats, not for keys or tokens.

Why does the histogram look jagged for small N?

Finite-sample noise. For a 'cleaner' bell curve from the Normal distribution, raise the sample count and/or reduce the bin count.

What's the triangular distribution for?

Useful when you have a rough min/most-likely/max estimate (e.g., project task durations in PERT analysis) and need a bounded distribution that's not flat.

Related tools