The first assumption is that a bank decides to give 1,000 loans for $180,000 for a year.
It is considered that each one who defaults causes a total loss of $200,000 for the bank, with all operational costs included.

A Monte Carlo simulation is executed, for 10,000 times, and the distribution of the losses is illustrated in the histogram.
The Central Limit Theorem indicates that the loss distribution is approximately normal and can be defined by its expected value and standard deviation.
With these values, it is possible to calculate the exact value x, which is the interest rate that, on average, the bank breaks even:
    lp + x(1 - p) = 0


With an interest rate of about 2%, on average the bank will break even, but it has 50% chance to loose money.
The bank needs to calculate an interest rate which has smaller chance for this to happen.
So a new value of interest rate must be calculated, which has probability of 1% of loosing money.
Applying the formulas of expected value, standard error and standard units, it is possible to calculate the new interest rate.


With the code above, it shows that with an interest rate of about 3.5%, there is 1% of probability of the bank loosing money.


With the interest rate calculated above, the expected profit per loan is about $2,124, resulting in a total expected profit of about $2 million a year.
A Monte Carlo simulation illustrates the approximation.

With 100,000 times, the expected profit is about $2 million and the probability of losing money is about 1%, which corresponds to the theoretical approximation.


Case of higher loans

To maximize the profits, one can rely on the law of large numbers and increase n the number of loans, so even with higher probability of default, with higher interest rates, the bank still can make profit.
The new values for this case are as follow:


Following the law of large numbers, it is possible to calculate the number of loans that represents a probability of 1% of the bank losing money, on this new conditions.


The equations show that it is required a number of 22,163 loans so that the probability of loosing money is about 1%.
In this situation, the expected profit of the bank is about $14 million. Again a Monte Carlo simulation is run, to illustrate the approximation.


The Monte Carlo simulation agrees to the theoretical approximation.
The real problem, as ocurred in the financial meltdown in 2007, is that the law of large numbers relies on independent values, in this case, loans, to minimize the standard error. In the real world, many interconnected events may lead to completely larger errors.
The next code reruns the Monte Carlo simulation, with a slightly probability of changing the global default probability between 3% and 5%.


The case presented here is not independent, with an external factor changing the global default probability. The expected profit is still about $14 million. However, the probability of losing money is about 35% and the probability of losing over $10 million is about 24%. The distribution of the random variable obtained shows that it no longer follows a normal distribution.