BernSim BernSim

BernSim –Program that simulates a Bernoulli event in the population. Confidence limits of the proportion of an event in a population are determined by four different methods. Sample program calculates and graphically shows binomial distribution for a defined number of events.


Event with two outcomes are called Bernoulli event, and a random variable that describes them is called a Bernoulli random variable. Software BernSim consists of three independent parts.
Simulator – for the given number of members (proportion) of the population given properties is assigned by the random selection of assigned given property (Y = 1). The sample of given size are randomly sampled from the members of population. It examines how many members has the required properties (Y = 1).


1. The number of members of the population. Assign exact proportion of properties that are present in the population. The sample size of population is determined for required properties (Y = 1or true). Sampling can be repeated several times (Number of samples).
2. List of results. It is written for the number of members of the sample which was found with default properties and proportions (%) in the sample. The results list with Copy / Paste (right click) can be transferred to a spreadsheet (Excel) or word processor (Word).
3. The level of statistical confidence limits that are obtained by multiple sampling. The results can be shown as a histogram of the frequency for properties found in the samples. Histogram is allowed when the number of sampling > 100.
4. The confidence limits for proportions of Bernoulli events for a given sample size of the population could be determined by the large number of repeated sampling.
Binomial distributionNumerically and graphically shows the probability density function of the binomial distribution B(n, p) given by sample size (n) and proportion (successful) event in the sample (p).

Confidence interval  - Confidence limits is determined by the proportions of the given level of statistical significance. You can use one of four methods.

Let x be the number of successes in a random sample of size n. As success is observed if yi, i = 1, 2, . . . , n, has a specific characteristic; a failure is observed if yi does not have that characteristic. The proportion of successes in the sample is  p~=x/n, and the proportion in the population as p. In practice the value of the population parameter p is usually unknown and must be estimated from a sample of data. This sample estimate is obtained by counting the successes and dividing by the total number of trials.

The value of p is fixed but unknown, and it is within the upper pU and lower pL confidence limits. Probability that p lies between these values is
P(pL≤p≤pU )=y
where y is the  confidence level  (γ=1-α) with α as type I error or significant level for parameters p.

1. Enter the sample size.

2. Record number of successful outcomes (required properties) in the sample.

3. Specifies a statistical confidence level of proportion.

4. Results of confidence limits for proportion of properties in the population.
5. Selection method for the determination of confidence limits.
Four methods of confidence intervals can be distinguished:
1. Numerical method
To obtain an exact confidence interval must be numerically solve the pair of equations for pL and pU must be numerically solved


 This method works well for small and moderate sized values of n.

2. Clopper-Pearson interval
For 0 < x < n, the solution for pL and pU is found via value for the F-distribution


This method may encounter numerical difficulty with determining the F ratio percentiles for large degrees of freedom.
3. Wald interval
The method is based on the normal approximation to the binomial distribution. Lower limit and upper limit are


where   zy is the zy=1-α/2  percentile of a standard normal distribution. The method is well for large value of n (sample size > 100).
4. Wilson score interval
The lower and upper limit of the interval are defined as
where zy is the zy =1-α percentile of a standard normal distribution. The sample size should be large enough to approximate the binomial distribution B(n,p) with normal distribution N(np, np(1-p))./2 
Program (zip) You can download here.
Author: dr.sc. Mladen Tudor