# The science of finance/Risk calculation
## Probabilities in Economics

The mathematical theory of risk is the theory of probability. It was first designed for games of chance. It enables us to calculate their average gains, and their risks, provided that there is no cheating. It can also be applied to physical systems that contain a large number of molecules. Their random motion is brownian and cannot cheat. Probabilities are in Nature.
An economy is not a casino. Economic agents are not in brownian motion. What meaning can we then give to probabilities in economics?
We can measure a probability when a random experiment is reproducible. The precision of the measurement increases with the number n of repetitions of the experiment. For physical systems, n can be as large as the number of molecules, therefore billions of billions of billions, because the molecules are identical. This is why probabilistic physical measurements can be very precise.
The precision of an experiment is measured by the relative margin of error, the margin of error divided by the measured quantity. It can be shown that the relative margin of error is equal to the inverse of the square root of n, when n is large, for a random experiment repeated n times.
Economic agents are all different from each other. One is never the reproduction of the other. The conditions in which they are placed are also not reproducible, because times change, because we never go back. It therefore seems that in economics the maximum number of repetitions of an experiment is equal to one. This is not enough to measure a probability.
Economic agents are not identical but they are sometimes very similar. The same goes for the conditions in which they are placed. Economic probabilities are therefore sometimes measurable, with a precision that depends on the number of repetitions of the measurement and the greater or lesser resemblance between the various measurements. Often we must be content with very imprecise estimates.
Mathematical theory is useful first because it teaches us to reason about risks. When probabilities are measurable, mathematical models can also be good representatives of reality. How to measure risk?
The risk of a project is measured by the dispersion of its anticipated final revenue.
A random quantity X is defined with probabilities. If there are n possible outcomes X(i) where i varies from 1 to n, we assign to each of them a probability p(X = X(i)) between 0 and 1, both included. A probability equal to 1 means that the outcome is certain, or almost. It is infinitely unlikely that the outcome will not occur. If the probability is zero, the outcome is infinitely unlikely, almost impossible.
The sum over all i of the p(X=X(i)) is equal to 1, because it is certain that the outcome is one of the X(i).
$\sum _{i}p(X=X(i))=1$
The mean E(X), also called the average or the expected value of X, is the sum over all i of p(X = X(i)) X(i).
$E(X)=\sum _{i}p(X=X(i))X(i)$
The mean of the absolute value of the deviations from the mean is a measure of dispersion, but the standard deviation, the square root of the mean of the squares of the deviations from the mean, is generally preferred because it is often easier to calculate.
The variance var(X) is the mean of the squared deviations from the mean.
$var(X)=\sum _{i}p(X=X(i))(X(i)-E(X))^{2}=E((X-E(X))^{2})$
The standard deviation std(X) is the positive square root of the variance.
$std(X)={\sqrt {var(X)}}$
The standard deviation measures the dispersion of a random quantity but it is not the only indicator of risk, because deviations from the mean can be dispersed in very different ways for the same standard deviation. The distribution of deviations from the mean, not just their standard deviation, can influence the assessment of risk. But in most cases, the standard deviation is considered a sufficient measure of risk.
The risk of a project is the standard deviation of its anticipated final revenue.
Profit is the difference between the final revenue and the initial cost. If the initial cost is fixed, the standard deviation of the profit is equal to the standard deviation of the final revenue and is therefore a measure of the same risk. The surplus profit is the difference between the profit of the project and the profit it would have earned if its initial cost had been invested at the risk-free rate. If the initial cost is fixed, the standard deviation on the surplus profit is therefore equal to the standard deviation on the profit and is also a measure of the same risk. We have therefore proven:
Theorem: if its initial cost is fixed, the risk of a project is the standard deviation of its anticipated surplus profit.

## The compensation of risks

The risks of one project may be offset by the risks of one or more other projects. Risk reduction by compensation is an example of value creation by composition of projects or options, because risk must be counted as a cost.
Consider a coin toss shooter. One can bet on tails by risking 1 with a 1 in 2 chance of winning 2. Betting on tails means acquiring an option to win 2. The price of this option is 1. The expectation of winning is also 1=0.5x2 . According to financial theory, the value of a project is not equal to its expected gain, the risk must be taken into account. For the same expected gain, a project has less value the more risky it is. We should therefore conclude that the price 1 to bet on tails and hope to win 2 is overvalued, since the project is risky, but this conclusion is false. We can compose the projects. The expected gain of several projects is the sum of the expected gain of each of them. If we bet heads and tails at the same time, we get a risk-free project to win 2. If the options to bet heads and tails cost less than 1, we could compound them and get a risk-free project to win 2 by paying less than 2. In this way, one could obtain without risk an unlimited profit from any initial bet, which is impossible. So the options to bet on heads or tails are correctly evaluated by their expected value. One can ignore their risk because it can be offset. The risk of betting heads can be offset by the risk of betting tails to get a risk-free project.
We can compose a risk-free portfolio with very risky options. The return on the risk-free portfolio thus composed is the weighted sum of the returns on the assets that make it up. If these assets had a higher return than the return of the risk-free assets, the risk-free portfolio thus composed would have a higher return than that of the other risk-free portfolios, and one could make an unlimited profit, without risk, simply by selling risk-free portfolios and buying a risk-free portfolio with a higher return. But the financial markets do not allow us to make unlimited profit without risk. So risky assets should be valued as if they were risk-free, as soon as they can be part of a risk-free portfolio. To evaluate a risky asset, one must take into account the risk, but not the risk inherent in the asset, only the minimal risk of a portfolio of which the asset is a component, because one can reduce the risks by composing portfolios, because one risk can be offset by another risk. A risk has a cost only if it cannot be offset. When valuing a financial asset, irreducible risk must be taken into account. It is the risk that cannot be further reduced by building a portfolio. Financial options and other assets should be valued as risk-free assets as soon as they can be part of a risk-free portfolio, because their risk can be reduced to zero.
A project, or an option, should not be evaluated as if it were isolated, separated from other projects, because then the cost of the risk could be overestimated. To evaluate a project, we must evaluate the irreducible risk, we must therefore evaluate the contribution of the project to the value of an optimal project, made up of several projects whose risks compensate each other partially or totally, in an optimal way. The same project can contribute to different projects, which have different risks, but if they are optimal projects, the value of its contribution is always the same. We reduce the risks by diversifying them, provided that they are independent, or not very dependent. When a project can be repeated several times, its risk can be reduced if its success each time is independent or little dependent on its success on previous and subsequent occasions.
Reducing risks may take time. Present risks can be offset by risks taken at later times. Present risks can be offset by risks taken at later times. Bad years can be offset by good years. The job of an insurance company is to reduce risks by offsetting them. If it does not reduce risks, or does not do so well enough, it is itself a risky business. Being insured by a company that is at risk of failure is about the same as not being insured at all.

## Independence, covariance and correlation

To calculate risk compensation, we must reason on the independence and covariance between random profits.
Two events A and B are independent if and only if the probability of their conjunction is the product of their respective probabilities, p(A and B) = p(A) p(B).
Two random quantities X and Y are independent if and only if all events X = X(i) are independent of all events Y = Y(j), p(X=X(i) and Y=Y(j)) = p(X=X(i)) p(Y=Y(j)), for all i and all j.
The covariance between two random quantities measures the correlation between the variations of one and the variations of the other. If the variations of one have on average the same sign as the variations of the other, the covariance is positive. If the variations of one have on average an opposite sign, the covariance is negative. Positive covariance means that the quantities vary more often in the same direction than in the opposite direction. Negative covariance means that they vary more often in the opposite direction than in the same direction. Zero covariance means that they vary as often in the same direction as in the opposite direction.
The covariance cov(X,Y) of two random quantities is the average of the products of their deviations from the average E( (X-E(X))(Y-E(Y)) )
cov(X,Y) = sum over all i and all j of p(X=X(i) and Y=Y(j))(X(i)-E(X))(Y(j)-E(Y)).
Theorems: for all random quantities X, Y, Z and any real number a,
* cov(X,Y) = cov(Y,X)
* cov(X,X) = var(X)
* cov(X,a) = 0
* cov(X,Y+Z) = cov(X,Y) + cov(X,Z)
* cov(X,Y+a) = cov(X,Y)
* cov(X,aY) = a cov(X,Y)
Proofs: they follow immediately from the definition of covariance.
* var(X+Y) = var(X) + 2cov(X,Y) + var(Y)
Proof: var(X+Y) = cov(X+Y,X+Y) = cov(X,X) + 2cov(X,Y) + cov(Y,Y)
Theorem: if the random quantities X and Y are independent then their covariance is zero.
Proof: $cov(X,Y)=\sum _{i,j}p(X=X(i))p(Y=Y(j))(X(i)-E(X))(Y(j)-E(Y))=\sum _{i}p(X=X(i))(X(i)-E(X))\sum _{j}p(Y=Y(j))(Y(j)-E(Y))=0$, because $\sum _{i}p(Y=Y(j))Y((j)=E(Y)$ and $\sum _{j}p(Y=Y(j))=1$.
The correlation coefficient cor(X,Y) of two random quantities X and Y is their covariance divided by the product of their standard deviations, cov(X,Y)/(std(X) std(Y)).
Theorem: if the correlation coefficient between two random quantities X and Y is strictly smaller than 1 then the risk of their sum X+Y is strictly smaller than the sum of their risks.
Proof: $(std(X+Y))^{2}=var(X+Y)=var(X)+2cov(X,Y)+var(Y)<var(X)+2std(X)std(Y)+var(Y)$ if $cor(X,Y)<1$. $(std(X)+std(Y))^{2}=var(X)+2std(X)std(Y)+var(Y)$, so $(std(X+Y))^{2}<(std(X)+std(Y))^{2}$ and $std(X+Y)<std(X)+std(Y)$.
In particular, if X and Y are risky and independent, the risk of their sum is strictly smaller than the sum of their risks.
Theorem: if the correlation coefficient cor(X,Y) between two random quantities X and Y is equal to 1 then there exist two real numbers a and b, a > 0, such that Y = aX +b almost always.
A statement is true almost always, or almost everywhere, when its probability is equal to 1.
Lemma: if var(X) = 0 then X = E(X) almost always.
Proof of the lemma: if the probability that X is different from E(X) is not zero, then the probability that (X - E(X))² > 0 also, and var(X) > 0. Proof of the theorem: let a = std(Y)/std(X). var(Y - aX) = var(Y) - 2a cov(X,Y) + a²var(X) = 0 because cov(X,Y) = std(X)std(Y). So Y - aX = E(Y) - a E(X) almost always. Hence the theorem. When Y = aX +b for two constants a and b, we say that Y is an affine function of X.
In the following, we will not distinguish a statement that is almost always true from a statement that is simply true.

## Optimal projects

If an economy could be divided into many independent projects, such that the success or failure of one project did not depend on the success or failure of the others, then it would be possible to offset all the risks, and to obtain for the economy as a whole a risk almost equal to zero. But projects in the same economy are not generally independent. The prosperity of some depends on the prosperity of others. The ruin of one can lead to the ruin of others. This is why there are risks that cannot be offset. Risks are sometimes irreducible because the agents of the same economic system are interdependent. Irreducible risks are systemic.
A project is optimal if and only if it has the smallest risk among all projects that have the same average profit and the same initial cost. The risk of an optimal project is irreducible, in the sense that it cannot be reduced without reducing the average profit.
The previous definition of an optimal project is equivalent to the following: a project is optimal if and only if it has the largest average profit among all projects that have the same risk and the same initial cost.
Optimal profits should be evaluated with market prices, average prices or ordinary prices. They represent the investment opportunities available to the economy as a whole. If there are bargains, very favorable prices compared to ordinary prices, they should not be counted when evaluating optimal profits, because they are only special conditions of a lucky agent , and they do not represent the economy as a whole.

## Leverage on an optimal project

Leverage varies the initial cost of a project by varying its final revenue. One might hope that it could transform a suboptimal project into an optimal project, but this hope is vain:
Theorem: if a project is optimal, it remains optimal if it is partially or totally financed by a loan at the risk-free rate, therefore taking advantage of the leverage effect.
Proof: borrowing reduces the average profit, because the interest must be repaid, but it does not change the dispersion of profits, because the interest is fixed in advance. Therefore, the risk of the project is not changed by borrowing. The surplus profit is not changed by the financing method, and it is optimal for the risk of the project. The project is therefore optimal regardless of its financing method.
A risky project is represented by a series of random costs and revenues, all dated, from which we can calculate an initial cost, a final revenue, a profit and a surplus profit, all random. Let X be the random quantity that represents the surplus profit of a risky project.
Theorem: if X is the random surplus profit of an optimal project whose initial cost C is not random, then X is also the random surplus profit of an optimal project whose initial cost is D, whatever D.
Proof: if D < C, it is sufficient to borrow C - D at the risk-free rate to bring the initial cost back to D without varying the surplus profit. If D > C, it is sufficient to lend D - C at the risk-free rate to increase the initial cost from C to D without varying the surplus profit.
If the initial cost is random, it can be set at an arbitrary value, possibly zero, by deciding to borrow all the costs that are not covered either by this initial sum fixed in advance or by revenues. An optimal project is therefore characterized only by its random surplus profit, not by its initial cost:
Theorem: a project is optimal if and only if it has the smallest risk among all projects that have the same average surplus profit.
Proof: This is an immediate consequence of the previous theorem.

## The composition of optimal projects

Theorem: if X is the random surplus profit of an optimal project, then aX is also the surplus profit of an optimal project, if a > 0.
Proof: if a < 1, it is enough to buy a share a of project X to obtain an optimal surplus profit aX. If a > 1, it is enough to increase the size of project X by a factor a.
A project is optimal for market conditions, which are assumed to be unlimitedly reproducible. This is why it is assumed that the size of an optimal project can always be increased. This is a theoretical simplification. In reality, there are always limits to the increase in the size of projects.
Theorem: if X and Y are the random surplus profits of two optimal projects, then X + Y is also the random surplus profit of an optimal project.
Proof: if we buy X and Y, we obtain a project whose random surplus profit is X + Y. If the risk of X + Y were smaller than the sum of the risks of X and Y, the risks of X and Y could be reduced by pooling them and sharing their common risk and X and Y would not be optimal surplus profits. So the risk of X + Y cannot be smaller than the sum of the risks of X and Y and therefore cannot be reduced.

## The correlation between all optimal projects

Theorem: two risky optimal projects cannot be independent. Proof: if they were independent, the risks could be reduced by combining them. However, optimal projects have a risk that cannot be reduced. Therefore, they are not independent.
In particular, repeating the same risky optimal project does not reduce its risk because successive projects are not independent of each other.
The dependence between optimal projects is very strong. All optimal projects are very closely correlated:
Theorem: the surplus profits of optimal risky projects are all strictly positive multiples of the same random quantity.
Proof: Let X and Y be the surplus profits of two risky optimal projects. The risk std(X+Y) of their sum is equal to the sum std(X) + std(Y) of their risks, otherwise combining them would reduce the risk and they would not be optimal. So cor(X,Y) = 1. So Y = aX + b, where a and b are constants, and a > 0. Y and aX are both optimal surplus profits, so b = 0. The surplus profits of the risky optimal projects are all multiples of each other, so all multiples of only one of them. Hence the theorem.
This theorem is very surprising, almost incredible, and one can even be afraid that it could lead to absurdities. Optimal projects can be carried out in different places and at different times. However, it is enough to know the final revenue of a single optimal project to know the final revenue of all optimal projects. For example, the final revenue of an optimal project that ends here and now should be enough to know the final revenues of present or future optimal projects everywhere in the world. Carrying out a single optimal project should therefore be like a crystal ball that would enable one to predict the results of all present and future optimal projects. But then these projects would not be risky any more since their final revenues would be known in advance. Carrying out a single optimal project and observing its result should therefore be enough to reduce all risks to zero, and we would no longer need risk theory and insurance companies.
We cannot find this crystal ball because we can never know if a risky project is optimal. We cannot know it before carrying it out, because the probabilities of the final revenues cannot be known precisely. We cannot know it after carrying it out either, for the same reason.
When we estimate the risk to identify an optimal project, we cannot conclude that it is really optimal, because our estimates are never precise enough, we can only conclude that it is perhaps not very different from an optimal project.
The existence of a single random quantity representative of all risky optimal projects is a consequence of the mathematical model. It assumes that all probabilities of all events are exactly defined in advance, as if all probabilities were written in advance with an infinite number of decimal places. Such exactness of probabilities cannot exist in reality, because nothing is ever exactly reproducible. That is why a single risky optimal project that represents all the others cannot exist in reality. It has only a mathematical existence.
Even if it exists only in a mathematical way, the unique random quantity representing all optimal risky projects has a realistic meaning. It means that agents who carry out optimal risky projects are all in the same boat. They all win together or they all lose together, but the losses of some cannot be compensated by the gains of others, otherwise the risk would be reducible.
When we bet against irreducible risk, we bet on the success of all those who also bet against irreducible risk, so we are all united, we do not play against each other. We are encouraged to bet if we believe that we will all succeed together. We are discouraged from betting if we believe that we will all lose together. The incentive to carry out risky optimal projects is based on the solidarity between all those who take risks and their hopes.
When we bet against an irreducible risk, we acquire a right to a share of the profits of the hoped-for collective success, but we commit at the same time to suffer a share of the losses, if it is a collective failure.
Risk takers are those who have the means to advance money, therefore the capitalists. To optimize their investments, they have an interest in all being united, therefore in thinking like socialists or communists. So we have proven:
Theorem: to be good financiers, we have to think like communists.

## Risk and time

Time can have several effects on risk:
* Time can increase risk, because it takes time to make profits. The more time passes, the more profits can increase, the more their dispersion also increases, so the risk increases.
* Present risks can be offset by future risks. The passage of time therefore reduces risk by intertemporal compensation: good years compensate for bad years.
* The further away a project is in time, the more difficult it is to anticipate its final revenue. Therefore, the revenue of a project is riskier if it is further away in time. This distance from the final revenue is reduced as time passes. Therefore, the passage of time reduces risk by reducing uncertainties.
To assess risks, we must estimate probabilities by taking into account all available information.
A project is relatively optimal when it is optimal for given probabilities.
A portfolio is managed dynamically when its composition is modified over time.
A portfolio is static if its composition is constant.
New information arrives at all times and can lead us to improve our probability estimates and reduce uncertainties. Relatively optimal projects can therefore change over time. The more time passes, the better our assessment of optimal projects and the more we are able to reduce risks. If we do not manage a project dynamically, we neglect this possibility of reducing risk and therefore risk losing more money. A portfolio or project must therefore be managed dynamically to remain relatively optimal.