liveBook · Manning

Prior probability

As explained in Build a Robo-Advisor with Python (From Scratch)

A prior distribution is a probability distribution representing beliefs about an unknown quantity before incorporating observed data.

A prior probability is the probability assigned to an event before additional evidence is considered. In Bayes’ rule, it is written as P(A); evidence enters through a likelihood, and the updated probability is the posterior P(A|B). section 12.2

For an unknown parameter θ, a prior can be a full probability distribution rather than one number. Bayesian updating combines that distribution with data to form a posterior distribution, treating θ as uncertain rather than fixed. section 12.2

Prior returns in Black–Litterman

Expected asset returns begin with a multivariate normal prior having mean μ and covariance Σ + C. Here, C represents uncertainty in expected returns; a common convention sets C = τΣ, preserving the return-correlation structure while scaling uncertainty. section 12.3.3 section 12.3.1

Investor views supply uncertain evidence: AR is modeled as normally distributed with mean b and covariance Ω. Updating the prior with these views yields a normal posterior mean and covariance, which can then feed standard asset-allocation optimization. section 12.3.3 section 12.3.2

Listing 12.1 Posterior mean and covariance
import numpy as np
import pandas as pd 

def compute_posterior_mean(mu, C, A, b, omega):
    c_inv = np.linalg.inv(C)
    a_t_oinv = A.T @ np.linalg.inv(omega)  #1

    er = np.linalg.inv(c_inv + a_t_oinv @ A) @ (c_inv @ mu + a_t_oinv @ b)

    return pd.Series(er, index=mu.index)

def compute_posterior_cov(sigma, C, A, omega):
    return sigma + np.linalg.inv((np.linalg.inv(C) + A.T @ omega @ A))    

Use the posterior-mean and posterior-covariance functions to implement the normal-distribution update for general C, A, b, and Ω inputs. section 12.3.3

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Defines priors through Bayes’ rule and specifies multivariate-normal update formulas, while deferring their mathematical derivation.
Examples
Uses professional basketball and height events, then multivariate expected returns and uncertain investor views.
What it assumes
Introduces Bayes-rule vocabulary through binary events before extending it to distributions over uncertain parameters.
What you can do after
Apply it via Python functions to update equilibrium return estimates and covariance before asset-allocation optimization.
How it connects
Connects prior probability to likelihood, evidence, posterior probability, conditional probability, expected returns, covariance, and investor views.

Also explained in

Compare how 8 books explain prior probability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.