# Minimal Principal Component example

I was looking for some minimal principal component example to complement the Wikipedia entry on this topic. Unfortunately, I was only able to find lengthy pages that tried to explain more than I was looking for with obfuscating calls to exotic library functions. So here is my example that generates the following figure.

```
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
# A simple function that returns normalized data and statistics
def normalize (x):
= np.mean(x)
meanx = x - np.array([meanx]*len(x))
xzm = np.std(xzm)
stdx = x/np.array([stdx]*len(x))
xn return xn, meanx, stdx
# Generate plausible Length (m) and weight (kg) data
= np.random.uniform(140, 190, 300)
l = 0.8*l - 90 + np.random.uniform(20, size = len(l))
w = normalize (l)
ln, ml, sl = normalize (w)
wn, mw, sw
# PC's are the eigen vectors for the co-variance matrix
= np.array([ln, wn])
xy = np.cov (xy)
C = np.linalg.eig (C)
W, v
# Sort and scale components
if W[0] > W[1]:
= np.sqrt(W[0])*v[:,0]
Pc1 = np.sqrt(W[1])*v[:,1]
Pc2 else:
= np.sqrt(W[1])*v[:,1]
Pc1 = np.sqrt(W[0])*v[:,0]
Pc2 = [sl, sw]*Pc1
PC1 = [sl, sw]*Pc2
PC2
# Generate figure
= plt.subplots()
fig, ax
ax.grid()= 'data')
ax.scatter (l, w, label 0], PC1[1], width = 0.5,
ax.arrow (ml, mw, PC1[= True, color = 'k', label = '1st PC')
length_includes_head 0], PC2[1], width = 0.5,
ax.arrow (ml, mw, PC2[= True, color = 'gray', label = '2nd PC')
length_includes_head
ax.legend ()'length [m]', size = 17)
plt.xlabel ('weigth [kg]', size = 17)
plt.ylabel (1.0/ax.get_data_ratio(), adjustable='box')
ax.set_aspect (True)
ax.set_axisbelow ("PCA.svg") fig.savefig (
```

# Debian, stably broken?

A few months ago I noticed a small bug in the `doas`

program
as provided via the Debian Bullseye (current stable) repositories:
Although the documentation describes a certain feature, it is not
available. After an online search, it appeared that this is a known
issue, and the maintainer was quick to implement a patch.
Problem solved? No, apparently the idea behind Debian’s stable branch is
that fixes needed to be tested. Depending on the timing, this can take
years, until the next stable release in introduced. Meaning that one is
left with three main options:

- Migrate to the testing branch.
- Install the program via an other methods (e.g. using Flatpak, from source, etc)
- Live with it

I have chosen the former option. So far, Debian Bookworm has worked very well for me. But I do not like the daily update routine, and in retrospect, i should have gone for the last option.