calibrate: pin R roles and line columns in the unit test; doc: false rejects can have R as candidate

Soul rinv s1 findings r-roles-unpinned and reject-in-r-candidate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Weksa 2026-11-13 13:48:54 +00:00
commit 5a681b2c3a
3 changed files with 33 additions and 7 deletions

View file

@ -1293,13 +1293,10 @@ fn main() -> Result<()> {
c.name, t.prompted.trials, t.prompted.nogain, t.prompted.accepted, t.prompted.regressed, t.noise
))
);
for (side, k) in [("r-candidate", t.r_candidate), ("r-base", t.r_base), ("r-free", t.r_free)] {
for (side, k) in t.r_roles() {
println!(
"{}",
run.labelled(&format!(
"calibrate class={} prompted-{side} trials={} nogain={} accepted={} regressed={}",
c.name, k.trials, k.nogain, k.accepted, k.regressed
))
run.labelled(&format!("calibrate class={} prompted-{side} {}", c.name, k.line()))
);
}
for (label, d) in degraded.iter().zip(&t.degraded) {

View file

@ -1886,6 +1886,11 @@ impl Counts {
}
}
/// The `trials=.. nogain=.. accepted=.. regressed=..` text of a calibrate line.
pub fn line(&self) -> String {
format!("trials={} nogain={} accepted={} regressed={}", self.trials, self.nogain, self.accepted, self.regressed)
}
fn plus(self, o: Counts) -> Counts {
Counts {
trials: self.trials + o.trials,
@ -1919,6 +1924,14 @@ pub struct Trials {
pub noise: f64,
}
impl Trials {
/// The prompted trials by the recorded lowering `R`'s role, labelled as the
/// calibrate lines print them.
pub fn r_roles(&self) -> [(&'static str, Counts); 3] {
[("r-candidate", self.r_candidate), ("r-base", self.r_base), ("r-free", self.r_free)]
}
}
/// Every `k`-subset of `pool`, in order.
fn subsets(pool: &[usize], k: usize) -> Vec<Vec<usize>> {
if k == 0 {
@ -3101,6 +3114,20 @@ mod tests {
// A far better draw is accepted in every trial.
assert_eq!(t.candidate.accepted, t.candidate.trials);
// R (port 0) scores above the other prompted draws: it is Accepted as a
// candidate and Regressed as a base, and the trials without it read NoGain.
let mut r_high: Vec<_> = (0..6).map(|s| draw(2, 8, if s == 0 { 0.8 } else { 0.6 }, 0.02, s)).collect();
let t = calibration_trials(&r_high, 6, 0, 0);
let [(cl, c), (bl, b), (fl, f)] = t.r_roles();
assert_eq!((cl, bl, fl), ("r-candidate", "r-base", "r-free"));
assert_eq!((c.accepted, c.regressed), (c.trials, 0));
assert_eq!((b.regressed, b.accepted), (b.trials, 0));
assert_eq!((f.nogain, f.trials), (80, 80));
assert_eq!(b.line(), "trials=20 nogain=0 accepted=0 regressed=20");
assert_eq!(c.line(), "trials=20 nogain=0 accepted=20 regressed=0");
assert_eq!(f.line(), "trials=80 nogain=80 accepted=0 regressed=0");
r_high.clear();
// Identical prompted draws: nothing to gain, nothing regressed, no noise.
let same: Vec<_> = (0..6).map(|_| draw(2, 8, 0.6, 0.02, 1)).collect();
let t = calibration_trials(&same, 6, 0, 0);

View file

@ -32,8 +32,10 @@ draws; the floor size is `FLOOR_ARMS_MIN` (3), the live rule's.
exchangeable with a repeat.) The prompted line is therefore printed three
more times, by `R`'s role in the trial: `prompted-r-candidate` (`R` is the
candidate), `prompted-r-base` (`R` is the base) and `prompted-r-free` (`R` is
neither; it may sit in the floor). The three sum to the prompted line. A false
accept is read from the first, a false reject from the second, and the third
neither; it may sit in the floor). The three sum to the prompted line. Read the Accepted
and Regressed columns of each line: a false accept sits mostly under the
first and a false reject under the second, but `R`-as-candidate trials can
Regress too (class `old` on `growth-scene`: 5 of its 15). The third
is the exchangeable rate: on `growth-scene` it was 0 Accepted and 0 Regressed
of 80 while all 11 false accepts and 9 false rejects involved `R`. Which of
the two rates the live rule should be held to is undecided: the live loop