////public Vector getVectors(int index, int CheckCnt) ////{ //// Vector v = Vector.Zero(0); //// for (int c = 0; c < 10; c++) //// { //// for (int r = index - CheckCnt + 1; r <= index; r++) //// { //// v.Append(double.Parse(Data[r].ValueList[c])); //// } //// } //// return v; ////} public Dictionary <string, double> OccurColumnProb(int col, int shiftCol, int TestLength, int LastTimes) { Dictionary <string, double> ret = new Dictionary <string, double>(); BayesDicClass bdic = OccurrDir(col, shiftCol, TestLength, LastTimes); ret = bdic.getBA(); return(ret); }
public Dictionary <int, Dictionary <int, double> > OccurProbDetailList(int shift, int TestLength, int LastTimes, int SelectListCnt) { Dictionary <int, Dictionary <int, double> > ret = new Dictionary <int, Dictionary <int, double> >(); for (int i = 0; i < 10; i++) { Dictionary <string, double> res = OccurColumnProb(i, shift, TestLength, LastTimes); string str = Data.LastData.ValueList[i]; //最后记录对应i名的车号 int col = (i + 1) % 10; Dictionary <int, double> colList = BayesDicClass.getBAMaxNProbValue(res, int.Parse(str), SelectListCnt); //该列上,以该车号为条件B推出所有车号的概率 ret.Add(col, colList); } return(ret); }
public Dictionary <int, List <int> > OccurProbList(int shift, int TestLength, int LastTimes, int SelectListCnt) { Dictionary <int, List <int> > ret = new Dictionary <int, List <int> >(); for (int i = 0; i < 10; i++) { Dictionary <string, double> res = OccurColumnProb(i, shift, TestLength, LastTimes); string str = Data.LastData.ValueList[i]; //str = str == "0" ? "10" : str; int col = (i + 1) % 10; List <int> colList = BayesDicClass.getBAMaxNValue(res, int.Parse(str), SelectListCnt); ret.Add(col, colList); } return(ret); }
BayesDicClass OccurrDir(int col, int shiftCol, int TestLength, int LastTimes, bool LastisSerial)//add by zhouys 2019/1/15 { BayesDicClass ret = new BayesDicClass(); int iShift = Data.Count - TestLength; if (iShift <= LastTimes) //Data length must more than TestLength+LastTimes+1 { return(ret); } Dictionary <string, int> defaultDic = PKProbVector.getDefaultCombDic(); Dictionary <int, int> PreA = PKProbVector.InitPriorProbabilityDic(); Dictionary <int, int> PreB = PKProbVector.InitPriorProbabilityDic(); //for (int col=0;col<10;col++) //{ Dictionary <string, int> combDic = defaultDic; int BColIndex = (col + shiftCol) % 10; //对于大于10的取模 if (BColIndex < 0) //对于小于0的,+10 如:0 + (-1) = 9 { BColIndex = BColIndex + 10; } for (int i = iShift - 1; i < Data.Count; i++) { int CurrA = int.Parse(Data[i].ValueList[col]); int CurrB = int.Parse(Data[i - LastTimes].ValueList[BColIndex]); string key = string.Format("{0}_{1}", CurrA, CurrB); int cnt = combDic[key]; combDic[key] = cnt + 1; PreA[CurrA] = PreA[CurrA] + 1; PreB[CurrB] = PreB[CurrB] + 1; } ret.PosteriorProbDic = combDic; ret.PriorProbDicA = PreA; ret.PriorProbDicB = PreB; ret.TestLength = TestLength; //} return(ret); }