Contagion and computational modelling in financial networks 
YOU CAN CHOOSE ANY PROGRAMMING LANGUAGE TO SOLVE THE CASE.

First part:
The step how the financial network should build is in the working paper1. 
Generate ER (erdos renyi)network 
N=number of node (banks) 
P= connection probability 
The links between the nodes are the weights. 
The weights are calculated by this rule:
Also these two values A(IB)= 0.2 and A(M)=0.8 are not changing. 
It has been explained in the attached the working paper (working paper 1) that you have to follow very carefully in this part!
The start is to generate and simulate network with small size first a for example with 6 nodes then if it is working try the simulation with 100200 nodes. 
The solution for the first part is ended if you got this graph:


An example for Simulation: 

Choose a node randomly to be failed 
How many banks failed after the initial bank fail 
N= at least 100 bank number 2 fail 10 bank more failed contagion happened 
We are doing this simulation 200 times 150 cases contagion happened frequency 150/200 average over contagion cases.
After you got the perfect exactly the same shaped graph for this part you can start to do the second part. 
Second part: 
Stochastic block model simulation (do the same things as in the first part with the same data, but in this case the average degree is fix but the µ is different.) 
I attached a working paper2 for this part that you should follow. 
To explain the a stochastic block model (SBM) is an extended version of ErdosRenyi (ER) network (i.e. ER network with communities). 
While ER network is characterized by the connection probability p, the SBM is characterized by p and mu together. 
The parameter p determines the average degree (i.e. number of link in the SBM), whereas μ determines how separated two communities are. 
Please try, for example, μ=0.5, 0.1, 0.01 and compare the results with the case of ER network. 
When mu=0.5, the result should be same as the result of ER network.
The most important part from working paper 2:

Mu (µ) is a quantity showing how many links are outside of communities (i.e. not within communities) and called 'mixing parameter' because it shows how mixed (not separated) communities are mixed. 
mu is defined as: mu = (number of intercommunity links)/(number of all links) 
Let us consider a network with two communities. 
If mu=0, there is no link between these communities. All links are located within communities (i.e. all links are intracommunity links: nodes in the same communities are connected to each other) 
If mu=0.5, the number of intracommunity links and the number of intercommunity links are same (i.e. communities has no meaning). 
We use this mu to generate a stochastic block model (SBM), a random model for networks with communities. 
In fact, SBM is a kind of extended version of ErdosReyni (ER) model. 
While ER model requires N and p as input parameters, SBM requires N, pintra, and pinter as input parameters. (pintra is connection probability among intracommunity nodes and pinter is connection probability among intercommunity nodes). 
For an SBM having N nodes, the average outdegree z, and the mixing parameter mu, we can get (I skip the detail but you can derive the following probabilities if you try): 
pintra = 2*(1mu)*z/(N1) 
pinter = 2*mu*z/N 
As an example, let us consider a SBM with two communities (Nodes 1,2, .., 50 belong to community A and nodes 51, 52, ..., 100 belong to community B). 
The parameters for the SBM are given as N=100, z=4, mu=0.1. 
Then, the expected number of links in the network M=N*z = 400 (Note that we are dealing with directed network). 
Since mu=0.1, the expected number of intracommunity links = (1mu)*M = 360 and the expected number of intercommunity links = mu*M = 40. 
A brief algorithm to generate this SBM is given as below: 
Node pair 
(1, 2) > Both nodes 1 and 2 are in the same community (i.e. intra). Thus we make a directed link from node 1 to node 2 with probability pintra=2*(10.1)*4/99 
(1, 3) > Both nodes 1 and 3 are in the same community (i.e. intra). Thus we make a directed link from node 1 to node 3 with probability pintra=2*(10.1)*4/99 
... 
(1, 50) > Both nodes 1 and 50 are in the same community (i.e. intra). Thus we make a directed link from node 1 to node 50 with probability pintra=2*(10.1)*4/99 
(1, 51) > Node 1 and 51 are not in the same community (i.e. inter). Thus we make a directed link from node 1 to node 51 with probability pinter=2*0.1*4/100 
(1, 52) > Node 1 and 52 are not in the same community (i.e. inter). Thus we make a directed link from node 1 to node 52 with probability pinter=2*0.1*4/100 
... 
(1, 100) > Node 1 and 100 are not in the same community (i.e. inter). Thus we make a directed link from node 1 to node 100 with probability pinter=2*0.1*4/100 
(2, 1) > Both nodes 2 and 1 are in the same community (i.e. intra). Thus we make a directed link from node 2 to node 1 with probability pintra=2*(10.1)*4/99 
(2, 3) > Both nodes 2 and 3 are in the same community (i.e. intra). Thus we make a directed link from node 2 to node 3 with probability pintra=2*(10.1)*4/99 
... 
(99, 100) > Both nodes 99 and 100 are in the same community (i.e. intra). Thus we make a directed link from node 99 to node 100 with probability pintra=2*(10.1)*4/99 
The goal is to compare the extent and the frequency of contagion in an SBM with low mu (i.e. strong community) with the extent and the frequency of contagion in an SBM with high mu (i.e. weak community). 
Thus we can tell which network is more resistant. 
I am also asking for AT LEAST 5000 word explanations but it can be more if its required about the solution, so to explain step by step what results you got and how did you do that. The essay should be fully understandable without grammar mistakes. Also the explanation should be clear step by step explanation and related to the question so the stochastic block model and erdos renyi (ER) model comparison (first and second part) IN THE FINANCIAL NETWORK AND WORLD. I also ask to show clearly the results for the question like what is happening for example in the first part if 1 random bank fails and also in the second part if the µ is changing. The results and graphs should be included with explanations. It should have a summary as well.
The raw code should have been sent in script!
If you have any question do not hesitate to ask me! Thank you for your help. 
DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction  the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction  the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of