Empirical probability and why it works
In basic probability, we often define the probability of an event \(A\) using a model of the sample space.
In many real situations, however, we don’t know the true probability \(p=P(A)\) in advance — we observe data.
The most direct estimate is the empirical probability, also called the relative frequency.
If you repeat the same experiment \(n\) times and the event \(A\) happens \(k\) times, then the empirical estimate is
\[
\hat p = \frac{k}{n}.
\]
This number is easy to compute and has an intuitive meaning: it is the fraction of trials that were favorable.
Law of large numbers (stabilization)
A key reason empirical probability is useful is the law of large numbers.
Under typical assumptions (independent trials with the same true probability \(p\)), the running frequency
\[
\hat p(t)=\frac{k_t}{t}
\]
tends to stabilize near \(p\) as the number of trials \(t\) grows.
Early on, small samples can fluctuate a lot (for example, 3 successes out of 5 trials gives \(\hat p=0.6\), but that does not prove \(p=0.6\)).
As more data arrives, each new observation changes the fraction less, so the graph of \(\hat p(t)\) typically becomes less “jumpy”.
Uncertainty and confidence intervals
Even with a good estimate, there is always uncertainty because you only observe a finite sample.
A confidence interval provides a range of plausible values for the true \(p\).
One popular choice is the Wilson score interval, which is often more accurate than the simplest normal approximation,
especially when \(n\) is not large or when \(\hat p\) is close to 0 or 1.
With confidence level \(1-\alpha\) and a standard normal critical value \(z\), Wilson’s interval can be written in the form
\[
\left[\; \frac{\hat p+\frac{z^2}{2n}}{1+\frac{z^2}{n}} \;\; \pm \;\;
\frac{z}{1+\frac{z^2}{n}}\sqrt{\frac{\hat p(1-\hat p)}{n}+\frac{z^2}{4n^2}} \;\right].
\]
Intervals become narrower as \(n\) increases, reflecting that larger datasets reduce uncertainty.
How to use this tool
You can enter data as counts (\(k\) favorable out of \(n\)) or as a raw list of observations (like \(H,T,H,\dots\) or \(1,0,1,\dots\)).
The calculator outputs \(\hat p\) as a simplified fraction, decimal, and percent, and it can display a confidence interval if enabled.
The interactive visualization shows (1) a grid of trials and (2) a running estimate curve \(\hat p(t)\).
If you simulate an experiment with a chosen “true” \(p\), you can see how randomness affects short runs and how estimates stabilize over time.