コード例 #1
0
        public List <CategoricalDistribution> DoForwardBackward(object owner, IContextLookup globalVars)
        {
            var randomVariables   = TemporalModel.TransitionModel.GetRandomVariables(owner, globalVars);
            var transitionalModel = new FiniteBayesModel(TemporalModel.TransitionModel.GetNetwork(randomVariables));

            randomVariables = TemporalModel.SensorModel.GetRandomVariables(owner, globalVars, randomVariables);
            var sensoryModel = new FiniteBayesModel(TemporalModel.SensorModel.GetNetwork(randomVariables));

            var temporalMap = TemporalModel.GetReverseTemporalMap(randomVariables);

            var forwardBackwardAlgorithm = new ForwardBackward(transitionalModel, temporalMap, sensoryModel);

            var objEvidences = new java.util.ArrayList(Evidences.Count);

            foreach (List <PropositionInfo> propositions in Evidences)
            {
                var stepEvidences = new java.util.ArrayList(propositions.Count);
                foreach (PropositionInfo proposition in propositions)
                {
                    stepEvidences.add(proposition.GetProposition(owner, globalVars, randomVariables));
                }
                objEvidences.add(stepEvidences);
            }

            CategoricalDistribution objPrior = Prior.GetProbabilityTable(randomVariables);

            return(forwardBackwardAlgorithm.forwardBackward(objEvidences, objPrior).toArray().Select(o => (CategoricalDistribution)o).ToList());
        }