Contents

Application - [A6, A7]

Question
A6. Generate a m sequences of n trials distributed according a Binomial with success probability p and represent the following quantities: absolute frequency of success, relative frequency of success, “normalized” relative frequency of success.
A7. In the same chart, add also a vertical histogram representing the distribution of the above 3 types of frequencies on the last trial.

Application

The requested application works by taking as input the following values:

  • N: The number of trials to execute.
  • M: The number of paths.
  • Epsilon: The granularity to use for drawing the histogram columns. Intended in terms of ratio with the whole.
  • Frequency: The type of frequency wanted to depict.

The application presents a button “Compute” used to generate the distribution and display it on the bitmap. Changing the frequency type without repressing the “Compute” button will not show the requested frequency, without data modification.

The following screenshots will display how the application works.

Histogram
The histogram look fairly small because it was chosen to keep the ratio in which the full height of the viewport portion containing it will represent the highest possible column. That is all the paths converging in a single interval. This can be verified by changing the Epsilon input value.

../images/rel-eps1.png
Relative frequency with epsilon 1 to 100 and probability of 0.5
../images/abs-eps1.png
Absolute frequency with epsilon 1 to 100 and probability of 0.5
../images/norm-eps1.png
Normalized frequency with epsilon 1 to 100 and probability of 0.5
../images/rel-eps2.png
Relative frequency with epsilon 2 to 100 and probability of 0.7
../images/abs-eps2.png
Absolute frequency with epsilon 2 to 100 and probability of 0.7
../images/norm-eps2.png
Normalized frequency with epsilon 2 to 100 and probability of 0.7

Source Code

The source code can be found on Github and it can be downloaded as a ZIP file from the Release section.

To run the code from Visual Studio on your local machine remember to download the latest version of StatisticsLib and add it to project dependencies.