Works on this device
Random Distribution Visualizer
Choose a distribution, draw random values from it, and see how well the sample fits. The page shows a histogram of the sample next to the share that the distribution expects in every bar, and it compares the mean, the spread and the quartiles. A seed lets you draw the same picture again.
Choose a distribution
Check these values
The values are made in this browser. Nothing is sent to a server.
The histogram will show here
Choose Draw to make a sample.
The sample
How it was worked out
How to use the visualizer
- Choose a distribution and enter its numbers, for example the mean and the standard deviation of a normal distribution.
- Enter how many values to draw, from 10 to 20,000.
- Choose Draw. Choose it again for new values: with an empty seed every draw is different.
- Read the histogram and the table under it. Each bar shows the share of the sample and the expected share.
- To see the sample settle, choose How the picture settles as the sample grows in the first menu.
- To get the same values again, type the seed of that result into Seed under the other fields.
The distributions and how the values are made
Every value starts from numbers between 0 and 1 that a number generator makes from the seed. Call such a number u. Each distribution has its own method to turn u into a value.
| Distribution | Mean | Variance | How a value is made |
|---|---|---|---|
| Normal (mean μ, standard deviation σ) | μ | σ² | Box-Muller transform: √(−2 ln(1 − u1)) × cos(2π u2), and the same with sin, each × σ + μ |
| Uniform (from a to b) | (a + b) ÷ 2 | (b − a)² ÷ 12 | Inverse transform: a + (b − a) × u |
| Exponential (rate r) | 1 ÷ r | 1 ÷ r² | Inverse transform: −ln(1 − u) ÷ r |
| Binomial (n trials, chance p) | n × p | n × p × (1 − p) | Direct: count how many of n values of u are below p |
| Poisson (mean λ) | λ | λ | Knuth's product method: multiply values of u until the product is at or below e^(−λ); the count of factors minus 1 |
| Geometric (chance p) | 1 ÷ p | (1 − p) ÷ p² | Direct: draw u until one is below p; the number of draws |
| Whole numbers a to b, equal chance | (a + b) ÷ 2 | ((b − a + 1)² − 1) ÷ 12 | A whole number from random bytes, with no number favoured |
What the result shows
- The histogram. A measured quantity (normal, uniform, exponential) is cut into bars of equal width. A count (binomial, Poisson, geometric, whole numbers) gets one bar for each whole number. Beside each bar of the sample stands the expected share: the chance that one value falls in that bar.
- The measures. Mean, variance and standard deviation of the sample, its smallest and largest value and its quartiles, each next to the value of the distribution.
- The largest gap. The largest difference between a sample share and its expected share. For n values a gap of about 1 ÷ √n is usual.
- The values. Every value is listed in a text box, so that you can copy them or download them.
How the picture settles
A small sample looks rough. A large one comes close to the distribution. This is the law of large numbers. The usual distance between the sample mean and the mean of the distribution is σ ÷ √n, so you need four times as many values to halve it.
The second calculation shows this. It uses the first 10, 20, 50, 100 … values of one row of values, draws the running mean as a line, and puts the bars of three sample sizes side by side.
Worked example
Normal distribution, mean 0, standard deviation 1, 1,000 values, seed 7. The sample mean is 0.0278 and the sample standard deviation is 0.9812. The largest gap between a sample share and its expected share is 0.0183, which is below 1 ÷ √1000 = 0.032.
With the same seed, the first 10 values have a mean of 0.4876, far from 0. The first 100 values have a mean of −0.0061, and all 1,000 values have a mean of 0.0278. The usual distance for 1,000 values is 1 ÷ √1000 = 0.0316.
Limits you should know
- You can draw 10 to 20,000 values. A binomial value needs n random numbers and a Poisson value about λ + 1, so for large n or λ the number of values is limited to keep the work below 2,000,000 random numbers.
- Limits of the settings: n up to 1,000, λ up to 200, the chance p of a geometric distribution at least 0.01, and at most 10,000 whole numbers in a range.
- The histogram has at most 50 bars for a measured quantity and at most 60 for a count. Whole numbers are put in groups when there are more.
- The chart shows the expected share as a second set of bars, not as a smooth curve over the histogram.
- A seed is a whole number of up to 15 digits. A fresh seed is drawn with the secure random generator of your browser.
- The values follow from the seed by a fixed rule (the generator xoshiro128**). They are good for learning and for trying things out. Do not use them for passwords, prizes or anything secret.
- This page is for learning. It does not test whether your own data follow a distribution.