KTW controller

The Kelly–Taguchi–Weibull controller: allocation, loss, drift. Three algorithmic primitives combined to pilot both industrial processes and agent hyperparameters.

Three components, one decision logic

The KTW controller combines three well-established algorithmic primitives from statistics and information theory:

ComponentRoleQuestion it answers
KellyAllocationHow much should I intervene?
TaguchiCostHow much does the deviation from target cost me?
WeibullDriftIs the observed deviation noise or a real drift?

Taken separately, these three tools are well known in their original disciplines (finance, industrial quality, reliability). Their composition is the subject of the two INPI patents filed by Paul Obara in January 2026.

Kelly: how much to intervene

The Kelly formula (1956) computes the optimal fraction of a capital to bet on an event of known probability, given the gain / loss ratio. Transposed to industrial and agentic piloting, it computes the optimal intervention fraction to apply when we have an estimated probability that the deviation is a real drift.

Formally:

f* = (b · p − q) / b

Where b is the gain/loss ratio, p the probability of success, q = 1 − p.

When p is low (uncertain signal), f* tends toward 0 — we intervene little. When p is high (strong signal), f* grows quickly — we intervene firmly. The behavior is asymmetric: we reward certainty, we hold back on uncertainty.

Taguchi: which loss to minimize

The Taguchi quadratic loss function (1989) translates the gap between a measurement and its target into monetary or operational cost. Instead of a binary function (“good” / “bad”), Taguchi posits:

L(y) = k · (y − target)²

Where k is a constant empirically calibrated (unit reprocessing cost / tolerance deviation).

The interest: the further from target, the higher the loss grows non-linearly. The controller can therefore prioritize: a gap close to the target costs little, a distant gap costs a lot.

Weibull: which probability of drift

To estimate whether an observed deviation is a real drift or measurement noise, we fit a Weibull distribution on the last N measurements (N typically between 30 and 100 depending on the cadence).

The shape parameter β of the Weibull distribution characterizes the regime:

βRegimeInterpretation
β < 1Infant mortalityInitial defects that resolve themselves
β ≈ 1ExponentialStationary random noise
β > 1AgingDrift in progress, heavy tail

A value β > 1.5 with a sufficient sample signs a real drift. The controller derives a Bayesian probability P(drift) that feeds Kelly.

The composition

At every measurement, the controller produces a decision:

P     = P_Weibull(drift | recent sample)
L     = k · (y − target)²
f     = kelly_fraction(P, gain_loss_ratio)
δ     = f · L · sign(y − target)

correction = δ applied to the machine setpoint

Three decision zones emerge:

  • Noise (low P) — do nothing.
  • Doubt (intermediate P) — soft correction, wait for confirmation on the next measurements.
  • Drift (high P and strong L) — firm and immediate correction.
flowchart LR
    M["Measurement y(t)"] --> W["Weibull<br/>P(drift)"]
    M --> T["Taguchi<br/>L = k·(y-target)²"]
    W --> K["Kelly<br/>f(P)"]
    K --> D{"Decision"}
    T --> D
    D -->|"low P"| N["Noise<br/>do nothing"]
    D -->|"intermediate P"| S["Doubt<br/>soft correction"]
    D -->|"high P + strong L"| F["Drift<br/>firm correction"]

    classDef input fill:#F5F1E8,color:#2C3E42,stroke:#7DB5A5,stroke-width:2px;
    classDef calc fill:#F5F1E8,color:#2C3E42,stroke:#A86640,stroke-width:1.5px;
    classDef decide fill:#2C3E42,color:#F5F1E8,stroke:#1A262A,stroke-width:2px;
    classDef noop fill:#7DB5A5,color:#F5F1E8,stroke:#5E9384;
    classDef soft fill:#E99971,color:#F5F1E8,stroke:#C97A55;
    classDef firm fill:#C97A55,color:#F5F1E8,stroke:#A86640;
    class M input;
    class W,T,K calc;
    class D decide;
    class N noop;
    class S soft;
    class F firm;

This behavior makes the system antifragile in the Taleb sense: instead of oscillating at every noise, it waits until it has the statistical information needed before intervening, and learns from every observed drift.

The two KTW patents

Two INPI filings were registered on 8 January 2026 by Paul Obara:

KTW B1 — Modulated open-loop piloting

The B1 patent describes an open-loop architecture in which the correction is modulated by Kelly on the basis of a Weibull probability computed offline. The process receives the correction and applies it without automatic feedback loop.

Typical use case: batch processing where each batch is calibrated from the drifts observed on previous batches, but where the observation cycle does not allow continuous feedback.

KTW B2 — Closed-loop probabilistic piloting + reframing

The B2 patent goes further: the machine setpoint itself is dynamically reframed according to the observed drifts. The Weibull probability is updated at every measurement, and the algorithm distinguishes three cases:

  1. Random drift — the setpoint stays, the correction is instantaneous.
  2. Systematic drift — the setpoint is reframed (new setpoint).
  3. Out-of-spec — human alert, the process is no longer auto-pilotable.

Dynamic reframing is what distinguishes KTW from a classic PID: we do not only adjust the correction, we adjust the target.

Industrial use cases

75 cl bottle filler

A beverage filler must dispense 75.0 cl ± 0.3 cl. Without controller, the average drifts slowly downward (valve wear) and the operator recalibrates manually at every shift.

With KTW:

  • Weibull detects the transition to β > 1.5 regime from 30 measurements.
  • Taguchi measures the cumulative loss of the surplus paid without counterpart.
  • Kelly doses the correction so as not to overreact to isolated measurements.

Effect: continuously corrected drift, cumulative loss typically reduced by 30 to 60% over a quarter.

Cardboard packaging line

A packaging line presents drifts on the cardboard grammage. KTW pilots the press setpoint from output grammage measurements. The B2 dynamic reframing is particularly useful: when the cardboard supplier changes batch, the target must follow.

Application to agent orchestration

The same KTW controller pilots agent hyperparameters in Nika OS. The observed metric is no longer a physical measurement but a loss score computed on the pod’s tool calls and outputs.

Internal use cases:

HyperparameterMetric YKTW decision
Model choice (Opus / Sonnet / Haiku)Cost × latency × successKelly allocation between arms
Semaphore concurrency (1–6 pods)TTFL p95 + error_rateReduction if Weibull β > 1.5
Retry policyRetry rate × marginal costKelly fraction on retry vs. escalation
GPU provider routingCost × availabilityAllocation between RunPod / Scaleway / etc.
RAG k (number of chunks)Recall × latencyAdaptive per prompt class

When a pod’s loss crosses a threshold:

  1. The system does not kill the pod immediately (equivalent of “do nothing” in the noise zone).
  2. If the loss keeps growing past the intermediate threshold, it mutates the mutable primitives (temperature, retry policy, prompts).
  3. If the loss stays high after mutation, it escalates: WhatsApp alert → JSONL bus → review request to the human operator.

KTW in the mutation matrix

Nika OS distinguishes three tracks of primitive evolution. KTW occupies the third one:

TrackTargetsCadenceEvaluation
GEPASkill MD, prompts, doctrinesContinuous through LLM-judge tournamentPareto multi-objective
Ablation + DOEPython hooks, MCP configs, routing logicDiscrete, batchedMann-Whitney U + bootstrap CI
KTWOnline params (retry, model, semaphore, RAG k)Per-decision, onlineReal-time reward signal

KTW is used where the reward is measurable at decision time (cost, latency, boolean success). We do not apply KTW to an artifact that has no real-time reward signal — it would degenerate into random allocation.

Reference pseudo-code

def ktw_decide(y_t, target, history, k_taguchi, reward_ratio):
    # 1. Estimate drift probability via Weibull
    shape, scale = fit_weibull(history[-50:])
    p_drift = bayesian_drift_prob(shape, scale, history)

    # 2. Taguchi loss
    loss = k_taguchi * (y_t - target) ** 2

    # 3. Kelly fraction on the intervention
    p_success = sigmoid(p_drift)  # empirically calibrated
    q = 1 - p_success
    f_kelly = max(0, (reward_ratio * p_success - q) / reward_ratio)

    # 4. Composed decision
    direction = sign(y_t - target)
    correction = f_kelly * loss * direction

    return {
        "p_drift": p_drift,
        "loss": loss,
        "f_kelly": f_kelly,
        "correction": correction,
        "zone": classify_zone(p_drift, loss),
    }

The exact detail of calibration curves and thresholds per process class is the subject of the INPI filings and is not reproduced here.

Limits and anti-patterns

A few observed pitfalls:

  • No measurable reward signal — on an artifact whose evaluation is subjective (quality of a mail draft), KTW degenerates. Prefer GEPA.
  • Too rare data — Weibull fitting typically requires 30+ measurements. Below that, we use a conservative Bayesian prior.
  • Delayed reward — if the reward arrives 24h after the decision, KTW blocks on latency. Use an online surrogate heuristic + asynchronous audit.
  • Multi-arm with correlated arms — Kelly assumes independent arms. On very correlated models (Sonnet vs. Haiku from the same provider), we need to decorrelate via factorization or switch to Thompson sampling.

See also

  • Observability and controllers — the loss score of a pod, source of Y for KTW.
  • Doctrines — antifragility and the algos as tools doctrine explain why KTW is an invoked tool and not an LLM.
  • Source code and resources — KTW B1 and B2 patents, academic references (Kelly 1956, Taguchi 1989, Weibull 1951).
  • The main page of the BCUB3 Lab describes the patents in accessible terms, without formulas.