pub fn compute<U: IntoIterator<Item = PosteriorEvent>>(
        &self,
        universe: U,
        data: &Data,
    ) -> ModelInstance<Event, PosteriorEvent> {
        let mut joint_probs = HashMap::new();
        let mut payload = Payload::default();
        let (posterior_probs, marginal) = {
            let mut joint_prob = |event: &Event, data: &Data| {
                let p = self.joint_prob(event, data, &mut payload);
                joint_probs.insert(event.clone(), p);
                p
            };

            let posterior_probs: HashMap<PosteriorEvent, LogProb> = universe
                .into_iter()
                .map(|event| {
                    let p = self.posterior.compute(&event, data, &mut joint_prob);
                    (event, p)
                })
                .collect();
            let marginal = LogProb::ln_sum_exp(&posterior_probs.values().cloned().collect_vec());

            (posterior_probs, marginal)
        };

        ModelInstance {
            joint_probs,
            posterior_probs,
            marginal,
        }
    }
/// Compute model for a given universe of events.
Compute model for a given universe of events.
Compute model for a given universe of events .
pub fn compute<U: IntoIterator<Item = PosteriorEvent>>(
        &self,
        universe: U,
        data: &Data,
    ) -> ModelInstance<Event, PosteriorEvent> {
        let mut joint_probs = HashMap::new();
        let mut payload = Payload::default();
        let (posterior_probs, marginal) = {
            let mut joint_prob = |event: &Event, data: &Data| {
                let p = self.joint_prob(event, data, &mut payload);
                joint_probs.insert(event.clone(), p);
                p
            };
            let posterior_probs: HashMap<PosteriorEvent, LogProb> = universe
                .into_iter()
                .map(|event| {
                    let p = self.posterior.compute(&event, data, &mut joint_prob);
                    (event, p)
                })
                .collect();
            let marginal = LogProb::ln_sum_exp(&posterior_probs.values().cloned().collect_vec());
            (posterior_probs, marginal)
        };
        ModelInstance {
            joint_probs,
            posterior_probs,
            marginal,
        }
    }
pub fn compute < U : IntoIterator < Item = PosteriorEvent > > ( & self , universe : U , data : & Data , ) -> ModelInstance < Event , PosteriorEvent > { let mut joint_probs = HashMap :: new ( ) ; let mut payload = Payload :: default ( ) ; let ( posterior_probs , marginal ) = { let mut joint_prob = | event : & Event , data : & Data | { let p = self . joint_prob ( event , data , & mut payload ) ; joint_probs . insert ( event . clone ( ) , p ) ; p } ; let posterior_probs : HashMap < PosteriorEvent , LogProb > = universe . into_iter ( ) . map ( | event | { let p = self . posterior . compute ( & event , data , & mut joint_prob ) ; ( event , p ) } ) . collect ( ) ; let marginal = LogProb :: ln_sum_exp ( & posterior_probs . values ( ) . cloned ( ) . collect_vec ( ) ) ; ( posterior_probs , marginal ) } ; ModelInstance { joint_probs , posterior_probs , marginal , } }
Compute model for a given universe of events.
Compute model for a given universe of events .
&self
universe
U
data
&Data
&self
universe
U
data
&Data