kalman
kalman
¶
Kalman Filter for continuous player point potential tracking.
State model: x_{t+1} = x_t + w_t, w_t ~ N(0, Q_t) Observation: y_t = x_t + v_t, v_t ~ N(0, R_t)
Supports per-timestep noise overrides so that: - News shocks (injury) → inflate Q_t (true form can jump suddenly) - Fixture difficulty → inflate R_t (harder opponents → noisier observations)
KalmanFilter
¶
KalmanFilter(
process_noise: float = 1.0,
observation_noise: float = 4.0,
initial_state_mean: float = 4.0,
initial_state_covariance: float = 2.0,
)
1D Kalman Filter for tracking latent point potential.
| PARAMETER | DESCRIPTION |
|---|---|
process_noise
|
Default process noise variance (form drift rate).
TYPE:
|
observation_noise
|
Default observation noise variance (weekly point noise).
TYPE:
|
initial_state_mean
|
Initial state estimate.
TYPE:
|
initial_state_covariance
|
Initial state uncertainty (variance).
TYPE:
|
Source code in fplx/inference/kalman.py
inject_process_shock
¶
Inflate process noise at a specific timestep.
Use when news indicates a sudden form change (injury, transfer). process_noise_t = default_process_noise * multiplier.
| PARAMETER | DESCRIPTION |
|---|---|
timestep
|
Gameweek index.
TYPE:
|
multiplier
|
Process noise multiplier (>1 = more uncertainty about form drift).
TYPE:
|
Source code in fplx/inference/kalman.py
inject_observation_noise
¶
Adjust observation noise at a specific timestep.
Use for fixture difficulty: harder opponents → less predictable points. observation_noise_t = default_observation_noise * factor.
| PARAMETER | DESCRIPTION |
|---|---|
timestep
|
Gameweek index.
TYPE:
|
factor
|
Observation noise factor (>1 = harder fixture, noisier observation).
TYPE:
|
Source code in fplx/inference/kalman.py
clear_overrides
¶
get_process_noise_override
¶
set_noise_overrides
¶
set_noise_overrides(
process_noise_overrides: dict[int, float],
observation_noise_overrides: dict[int, float],
)
Replace per-timestep noise overrides.
Source code in fplx/inference/kalman.py
copy_with_overrides
¶
copy_with_overrides(
max_timestep: Optional[int] = None,
) -> KalmanFilter
Create a parameter-identical filter with copied noise overrides.
| PARAMETER | DESCRIPTION |
|---|---|
max_timestep
|
If provided, only overrides for timesteps <= max_timestep are copied.
TYPE:
|
Source code in fplx/inference/kalman.py
filter
¶
Run Kalman filter on observations with per-timestep noise.
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
filtered_state_means
|
Filtered state estimates (posterior mean).
TYPE:
|
filtered_state_covariances
|
Filtered state uncertainties (posterior variance).
TYPE:
|
Source code in fplx/inference/kalman.py
predict_next
¶
Predict next observation with uncertainty.
Returns the predictive distribution for Y_{t+1} (the observation), not X_{t+1} (the latent state). This ensures consistency with the HMM predict_next which also returns observation-level variance.
Var[Y_{t+1}] = Var[X_{t+1}|y_{1:t}] + R = (P_t + Q) + R
Must call filter() first.
| RETURNS | DESCRIPTION |
|---|---|
predicted_mean
|
E[Y_{t+1} | y_{1:t}].
TYPE:
|
predicted_var
|
Var[Y_{t+1} | y_{1:t}] (observation-level, includes R).
TYPE:
|
Source code in fplx/inference/kalman.py
smooth
¶
Run RTS smoother (backward pass after forward Kalman filter).
| PARAMETER | DESCRIPTION |
|---|---|
observations
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
smoothed_state_means
|
Smoothed state estimates.
TYPE:
|
smoothed_state_covariances
|
Smoothed state uncertainties.
TYPE:
|