GitHub profile

Step 1 - Specify the Prior

Notation

For each retained component $i \in {1,2,3}$, the score distribution is modelled as $z_i \sim \text{Normal}(\mu_i, \sigma_i^2)$, independently per component (matching the treatment in Classical PCA's score-distribution step). The non-informative prior places:

$$p(\mu_i) \propto 1 \qquad \text{flat over } (-\infty,\infty)$$

$$p(\sigma_i^2) \propto \frac{1}{\sigma_i^2} \qquad \text{Jeffreys prior, equivalent to a flat prior on } \log\sigma_i$$

Both are improper (see Priors — Proper vs improper priors). No likelihood is attached at this stage, so there is nothing to sample or plot yet: per the decision on Priors, prior predictive sampling is being skipped for this uninformative-prior pass, which is exactly what makes the true improper Jeffreys/flat prior usable here rather than a proper stand-in. The model becomes complete — and samplable via MCMC — once Step 2 adds the likelihood.

Python

filename: step1_prior.py

import pymc as pm

'''
non-informative prior for each component's score distribution: a flat prior on mu,
and a flat prior on log(sigma) (equivalent to a Jeffreys prior on sigma^2).
both are improper - no likelihood attached yet, see step 2 for that.
'''

def prior_model(components=("PC1", "PC2", "PC3")):
    with pm.Model() as model:
        for component in components:
            mu = pm.Flat(f"mu_{component}")
            log_sigma = pm.Flat(f"log_sigma_{component}")
            sigma = pm.Deterministic(f"sigma_{component}", pm.math.exp(log_sigma))
    return model
flat prior on mu, flat prior on log(sigma) (Jeffreys on sigma^2), independently for each component