Count the ten regional P4s as one station in the features; cap P(add on any station) at what the stations allow together (1 - prod(1 - p) over P3, P4, P5, P6, P8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 04:42:26 +00:00
co-authored by Claude Opus 5.5
parent c114da9a63
commit a357a9b7e4
4 changed files with 51 additions and 10 deletions
+18
View File
@@ -20,6 +20,24 @@ pub const C: usize = CHANNELS.len();
pub fn is_p4(c: usize) -> bool { CHANNELS[c].starts_with("p4") }
/// Station groups: P3, P4 (the ten regional P4s broadcast mostly the same national programme,
/// so they count as one), P5, P6 Beat, P8 Jazz.
pub const GROUPS: usize = 5;
pub fn group(c: usize) -> usize { match CHANNELS[c] { "p3" => 0, "p5" => 2, "p6beat" => 3, "p8jazz" => 4, _ => 1 } }
impl Panel {
/// The artist's plays in week w across station groups (P4 = the mean of the regions), optionally
/// leaving out one group.
pub fn group_total(&self, a: usize, w: usize, skip: Option<usize>) -> f64 {
let (mut p4, mut n4, mut tot) = (0.0, 0.0, 0.0);
for c in 0..C {
if Some(group(c)) == skip { continue; }
if is_p4(c) { p4 += self.y(a, c, w); n4 += 1.0; } else { tot += self.y(a, c, w); }
}
tot + if n4 > 0.0 { p4 / n4 } else { 0.0 }
}
}
pub struct Artist {
pub id: String,
pub name: String,