Posts

Linear-Quadratic Regulator

Last edited: August 8, 2025

An exact solution for a dynamic system with quadratic costs and linear differential equation describing the dynamics.

linearilzation

Last edited: August 8, 2025

For some non-linear function, we can use its first Jacobian to create a linear system. Then, we can use that system to write the first order Taylor:

\begin{equation} y’ = \nabla F(crit)y \end{equation}

where \(crit\) are critical points.

Phase Portrait stability

  • if all \(Re[\lambda] < 0\) of \(\qty(\nabla F)(p)\) then \(p\) is considered stable—that is, points initially near \(p\) will exponentially approach \(p\)

  • if at least one \(Re[\lambda] > 0\) of \(\qty(\nabla F)(p)\) then \(p\) is considered unstable—that is, points initially near \(p\) will go somewhere else

Linearity Tests

Last edited: August 8, 2025

CAPM, a Review

Note that we will be using the Sharpe-Linter version of CAPM:

\begin{equation} E[R_{i}-R_{f}] = \beta_{im} E[(R_{m}-R_{f})] \end{equation}

\begin{equation} \beta_{im} := \frac{Cov[(R_{i}-R_{f}),(R_{m}-R_{f})]}{Var[R_{m}-R_{f}]} \end{equation}

Recall that we declare \(R_{f}\) (the risk-free rate) to be non-stochastic.

Let us begin. We will create a generic function to analyze some given stock.

Data Import

We will first import our utilities

import pandas as pd
import numpy as np

Let’s load the data from our market (NYSE) as well as our 10 year t-bill data.

linked files

Last edited: August 8, 2025

linked files is a linked list: in every block, it stores the location of the next block; we don’t store files contiguously. We simply store a part of the file in a block, and a pointer to wherever the next block where the file is located is.

this solves the contiguous allocation’s fragmentation problem.

problems

  • massive seek time to get all the blocks for a given file: data scattered
  • random access of files (“find the middle”) is hard: can’t easily jump to an arbitrary location; we had to read the file from the start