More clean up

This commit is contained in:
2021-05-25 11:23:30 +02:00
parent a2ecd9b268
commit 2dca63b1c9
3 changed files with 16 additions and 24 deletions

View File

@@ -142,7 +142,9 @@ impl BinaryModel {
elems.extend(self.process_items(team_2, -1.0));
let prob = match self.win_obs {
BinaryModelObservation::Probit => probit_win_observation(&elems, t, 0.0, &self.storage),
BinaryModelObservation::Probit => {
ProbitWinObservation::probability(&self.storage, &elems, t, 0.0)
}
BinaryModelObservation::Logit => todo!(),
};

View File

@@ -169,14 +169,14 @@ impl TernaryModel {
let prob_1 = match self.obs {
TernaryModelObservation::Probit => {
probit_win_observation(&elems, t, margin, &self.storage)
ProbitWinObservation::probability(&self.storage, &elems, t, margin)
}
TernaryModelObservation::Logit => unimplemented!(),
};
let prob_2 = match self.obs {
TernaryModelObservation::Probit => {
probit_tie_observation(&elems, t, margin, &self.storage)
ProbitTieObservation::probability(&self.storage, &elems, t, margin)
}
TernaryModelObservation::Logit => unimplemented!(),
};

View File

@@ -3,18 +3,6 @@ use crate::utils::logphi;
use super::{f_params, Core, Observation};
pub fn probit_win_observation(
elems: &[(usize, f64)],
t: f64,
margin: f64,
storage: &Storage,
) -> f64 {
let (m, v) = f_params(&elems, t, &storage);
let (logpart, _, _) = mm_probit_win(m - margin, v);
logpart.exp()
}
fn mm_probit_win(mean_cav: f64, cov_cav: f64) -> (f64, f64, f64) {
// Adapted from the GPML function `likErf.m`.
let z = mean_cav / (1.0 + cov_cav).sqrt();
@@ -37,6 +25,13 @@ impl ProbitWinObservation {
margin,
}
}
pub fn probability(storage: &Storage, elems: &[(usize, f64)], t: f64, margin: f64) -> f64 {
let (m, v) = f_params(&elems, t, &storage);
let (logpart, _, _) = mm_probit_win(m - margin, v);
logpart.exp()
}
}
impl Observation for ProbitWinObservation {
@@ -81,15 +76,6 @@ impl Observation for LogitWinObservation {
}
}
pub fn probit_tie_observation(
_elems: &[(usize, f64)],
_t: f64,
_margin: f64,
_storage: &Storage,
) -> f64 {
unimplemented!();
}
pub struct ProbitTieObservation {
//
}
@@ -98,6 +84,10 @@ impl ProbitTieObservation {
pub fn new(_storage: &mut Storage, _elems: &[(usize, f64)], _t: f64, _margin: f64) -> Self {
todo!();
}
pub fn probability(storage: &Storage, elems: &[(usize, f64)], t: f64, margin: f64) -> f64 {
todo!();
}
}
impl Observation for ProbitTieObservation {