public int FindStateIndex(int att, int phase) { for (int i = 0; i < StateList.Count(); i++) { if (StateList[i].Att == att && StateList[i].Phase == phase) { return(i); } } return(-1); }
public void FillSimulatedData() { Random ran = new Random(); for (int i = 0; i < StateList.Count(); i++) { for (int j = 0; j < FreqList.Count(); j++) { Data[i, j] = Math.Cos(j * Math.PI * 2 / 1000 + i) + ran.NextDouble(); //System.Threading.Thread.Sleep(2); } } }
/// <summary>预测状态概率</summary> public void PredictProb() { PredictValue = new double[Count]; PredictValue1 = new Dictionary <int, double>(Count); //这里很关键,权重和滞时的关系要颠倒,循环计算的时候要注意 //另外,要根据最近几期的出现数,确定概率的状态,必须取出最后几期的数据 //1.先取最后K期数据 var last = StateList.GetRange(StateList.Count - LagPeriod, LagPeriod); //2.注意last数据是升序,最后一位对于的滞时期 是k =1 for (int i = 0; i < Count; i++) { for (int j = 0; j < LagPeriod; j++) { //滞时期j的数据状态 var state = last[last.Count - 1 - j] - 1; PredictValue[i] += Wk[j] * ProbMatrix[j][state, i]; if (double.IsNaN(PredictValue[i])) { try { var numberCount = StateList.Count(p => p == i + 1); PredictValue[i] = (double)numberCount / StateList.Count; } catch (Exception e) { var random = new Random(); PredictValue[i] = (double)random.Next(0, 100) / 100; } } } PredictValue1.Add(i + 1, PredictValue[i]); } }
public void ResetTestResult() { Data = new double[StateList.Count(), FreqList.Count()]; }