## Rich-get-richer Phenomenon and Aggregation

This examples demonstrates (i) a rich-get-richer phenomenon in the form of a multiplicative random process, and an (ii) aggregation of multiple random factors in the form of an additive random process.

Read carefully what you need to accomplish for this exercise. You need to submit your source code and 5 plots all-together. The instruction for plots are written in bold in the text below. For plotting use the provided functions in the Python template.

### Rich-get-richer

This example consists of two parts. For both parts you first need to create and randomly initialize a square grid:

1. Implement a 2d regular square lattice (i.e. a grid) with 100x100 cells.
2. Initialize each cell with a number drawn uniformly at random from the interval [0, 1).

#### Part A

You will simulate a growth of investments in market stocks. Each grid cell represents an investment and in each simulation step an investment can gain or lose up to 20% in value. For this part, use a random grid that you created as described above. Then, for this simulation implement a simple multiplicative process.

1. Iterate over 2) and 3) 30 times
2. Draw a 100x100 growth matrix of random numbers in the range [0.8, 1.2). This represents your growth rate.
3. Multiply element-wise your growth matrix from 2) with your grid cells and store the results in your grid. The new grid values keep the updated investments after this simulation step.
4. Plot the grid as a heat-map.
5. Plot the distribution of the values in your grid.

#### Part B

You will slightly modify the growth of investments in market stocks. Each investment is insured for a certain minimal value, i.e. a threshold. If an investment falls below the threshold the insurance company pays the money and resets it to the threshold value. For this part, use a random grid that you created as described above. Then, for this simulation implement a simple multiplicative process.

1. Reset all values below threshold to the threshold value. Take 1.0 as your threshold value.
2. Iterate over 3), 4) and 5) 30 times
3. Draw a 100x100 growth matrix of random numbers in the range [0.8, 1.2). This represents your growth rate.
4. Multiply element-wise your growth matrix from 3) with your grid cells and store the results in your grid. The new grid values keep the updated investments after this simulation step.
5. Reset all values below threshold to the threshold value.
6. Plot the grid as a heat-map.
7. Plot the distribution of the values in your grid.

### Aggregation

Suppose now we want to calculate the aggregate value of a random sample of a given number of investments. For this part use the final grid that you created in the Part B of "Rich-Get-Richer" example and then implement an additive random process:

1. Draw 10000 random samples of size 100 from the grid.
2. Calculate the sum of each of 10000 samples.
3. Plot the distribution of the sample sums.

Submit your source code and 5 plots. You will need to understand what do you see in your plots and most importantly you will need to understand why do you see that in your plots.