# berconfint

Bit error rate (BER) and confidence interval of Monte Carlo simulation

## Syntax

```[ber,interval] = berconfint(nerrs,ntrials) [ber,interval] = berconfint(nerrs,ntrials,level) ```

## Description

`[ber,interval] = berconfint(nerrs,ntrials)` returns the error probability estimate `ber` and the 95% confidence interval `interval` for a Monte Carlo simulation of `ntrials` trials with `nerrs` errors. `interval` is a two-element vector that lists the endpoints of the interval. If the errors and trials are measured in bits, the error probability is the bit error rate (BER); if the errors and trials are measured in symbols, the error probability is the symbol error rate (SER).

`[ber,interval] = berconfint(nerrs,ntrials,level)` specifies the confidence level as a real number between 0 and 1.

## Examples

If a simulation of a communication system results in 100 bit errors in 106 trials, the BER (bit error rate) for that simulation is the quotient 10-4. The command below finds the 95% confidence interval for the BER of the system.

```nerrs = 100; % Number of bit errors in simulation ntrials = 10^6; % Number of trials in simulation level = 0.95; % Confidence level [ber,interval] = berconfint(nerrs,ntrials,level)```

The output below shows that, with 95% confidence, the BER for the system is between 0.0000814 and 0.0001216.

```ber = 1.0000e-004 interval = 1.0e-003 * 0.0814 0.1216 ```

For an example that uses the output of `berconfint` to plot error bars on a BER plot, see Curve Fitting An Error Rate Plot

## References

 Jeruchim, Michel C., Philip Balaban, and K. Sam Shanmugan, Simulation of Communication Systems, Second Edition, New York, Kluwer Academic/Plenum, 2000.