18 lines
1.1 KiB
Markdown
18 lines
1.1 KiB
Markdown
|
Calculating the average doesn't gives as much data, on how the probabilities for each outcome are distributed.
|
||
|
So let's compute the frequency distribution, which tells you for every possible outcome, how often it happend after some iterations.
|
||
|
|
||
|
## Knowledge
|
||
|
|
||
|
For that we need a new language construct: The array. An array is like the variables before. But now we talk about a set of variables.
|
||
|
|
||
|
To declare an array you put open and closed braces behind the name with the number of elements behind it.
|
||
|
To access a single element you also put open and closed braces behind it with the number of the element you want to access.
|
||
|
So ``int array[6];`` declares an array of size six and ``array[0] = 42;`` sets the first element to 42.
|
||
|
The first element has always the index 0 and the last has an index of size-1.
|
||
|
|
||
|
## Task
|
||
|
|
||
|
Your task is to create an array with the appropriate size, to count up the frequency of each outcome.
|
||
|
The output of this program will be run through a [plotting program](http://www.gnuplot.info/). So when you hit the execute button,
|
||
|
you will see a text based graph of the distribution.
|