private ProtocolModel GetBestProtocolMatch(ProtocolModel observationModel, SortedList <String, ProtocolModel> protocolModels)
        {
            ProtocolModel bestProtocolMatch           = null;
            var           bestProtocolMatchDivergence = this.config.DivergenceThreshold; //the highest allowed distance for a valid protocol model match

            foreach (var protocolModel in this._protocolModels.Values)
            {
                var divergence = observationModel.GetAverageKullbackLeiblerDivergenceFrom(protocolModel);
                if (divergence < bestProtocolMatchDivergence)
                {
                    bestProtocolMatch           = protocolModel;
                    bestProtocolMatchDivergence = divergence;
                }
            }

            //just for test
            //ShowProtocolModelDivergences(observationModel, bestProtocolMatch);
            return(bestProtocolMatch);
        }
        private ProtocolModel GetBestProtocolMatch(ProtocolModel observationModel, SortedList <String, ProtocolModel> protocolModels)
        {
            ProtocolModel bestProtocolMatch           = null;
            var           bestProtocolMatchDivergence = this.config.DivergenceThreshold; //the highest allowed distance for a valid protocol model match

            foreach (var protocolModel in this._protocolModels.Values)
            {
                var divergence = observationModel.GetAverageKullbackLeiblerDivergenceFrom(protocolModel);
                if (divergence < bestProtocolMatchDivergence)
                {
                    bestProtocolMatch           = protocolModel;
                    bestProtocolMatchDivergence = divergence;
                }
            }

            //TODO I have no idea why this is not working...
            //var _protocolModelsDivergences = new double[_protocolModels.Values.Count];
            //var _protocolModelsResulting = new ProtocolModel[_protocolModels.Values.Count];
            //Parallel.ForEach(_protocolModels.Values, (i, state, index) =>
            //{
            //    _protocolModelsDivergences[index] = observationModel.GetAverageKullbackLeiblerDivergenceFrom(i);
            //    _protocolModelsResulting[index] = i;
            //});

            //for (int index = 0; index < _protocolModelsDivergences.Length; index++)
            //{
            //    double divergence = _protocolModelsDivergences[index];
            //    if (bestProtocolMatchDivergence > divergence)
            //    {
            //        bestProtocolMatchDivergence = divergence;
            //        bestProtocolMatch = _protocolModelsResulting[index];
            //    }
            //}

            return(bestProtocolMatch);
        }