You have been provided with 4 years of event data for 4 risks in the file risk_data.csv. The file is structured such that rows follow a repeated pattern of: row a = risk event occurrence, row b =risk loss occurrence. In total you will be supplied with 8 rows of data. Using the supplied data you must: 1) Model the frequency of the events using a Poisson Distribution 2) Model the Impact of the losses as a LogNormal distribution 3) Provide a Monte Carlo simulation of the four risks undertaking 10000 trials.
You will need to submit two files:
1) monte-carlo.py – contains your programme which runs the simulation and calculates the values ( no using pandas or numpy)
2) answers.pdf – a PDF file which contains your answers to the questions listed below
Your programme – monte-carlo.py – must:
1) Contain a function to ingest a list of numbers, each number representing the number of occurrences of a risk event and calculate the descriptive statistics (mean, median and variance) of the data. def describe_stats(data) returns tuple (mean, median, stddev) (2 marks)
2) Contain a function to ingest a list of numbers, each number representing the number of occurrences of a risk event and calculate the lambda value to use in a Poisson Distribution. def poisson_param(data) returns p_mu (1 marks)
3) Contain a function to ingest a list of numbers, each number representing a financial loss from the risk event, and calculate the mu, sigma and scale values to use in a lognormal Distribution def lognormal_param(data) returns tuple (ln_mu, ln_sigma) (7 marks)
4) Contain a function which takes as parameters the Poisson lambda, the Lognormal Mu, Sigma and the number of months to simulate and produces a Monte Carlo simulation data set for the risk with an entry for the total monthly loss. def monte_carlo_run(p_mu, ln_mu, ln_sigma, trials) returns [] of trials length (12 marks)
5) Be able to:
a. Calculate and display the answers to the questions below, (5 marks)
b. Run a Monte Carlo simulation for all four risks over 10000 trials, (12 marks)
c. Produce a loss exceedance curve for the four risk presented (10 marks)
d. Produce a probability density histogram with 500 bins for each risk. (6 marks)
6) You can get additional marks for quality and functionality, for example: (15 marks)
a. Loading the cvs file
b. Error handling and checking
c. Quality of the comments and code structure
For the data provided you must answer the following questions:
1) For each Risk in the csv data file what is the mean, median and variance of the data for the number of events and the losses for each risk (4marks)
2) For each risk what is the Mu/Lambda value for the Event Poisson Distribution Model and the Mu and Sigma for the loss lognormal distribution model (12 marks)
3) Using the simulation model parameters calculate the Expected Inherent Loss for each individual risk (2 marks)
4) Using the simulation parameters for each risk calculate the Expected Inherent loss of all the Risks in this model (1mark)
5) Using the LEC and MC simulation answer the following questions
a. What was the minimum simulated loss in a month?
b. What was the maximum simulated loss in a month?
c. What was the mean of the simulated inherent loss for the Monte Carlo simulation?
d. What is the probability (to 2 decimal places) of losses in a single month exceeding:
i. £30
ii. £300
iii. £3000
(6 marks)
6) Explain why the Expected Inherent Loss different to the mean of the Simulated Inherent Losses? (5 marks)
7) You must submit copies of our generated images in your answer file.