export function fitGradeThresholds(trainProbs) {
  const sorted = [...trainProbs].sort((a, b) => a - b);
  const q = p => sorted[Math.floor(p * sorted.length)];
  return { aMin: q(0.80), bMin: q(0.60), cMin: q(0.40) }; // A=top20%, B=top40%, C=top60%
}

export function toGrade(prob, t) {
  return prob >= t.aMin ? 'A' : prob >= t.bMin ? 'B' : prob >= t.cMin ? 'C' : 'D';
}
