Ejemplo n.º 1
0
        private ObservableCollection <Model.Structures.ResultData> ApproximateData()
        {
            var    data          = ResultData.Clone();
            var    approxData    = new ObservableCollection <ResultData>((IEnumerable <ResultData>)data);
            double sumCons       = 0;
            double sumTemp       = 0;
            double sumPres       = 0;
            double sumSquareCons = 0;
            double sumConsLevel  = 0;
            double sumConsPres   = 0;

            foreach (var mem in ResultData)
            {
                sumCons       += mem.Consumption;
                sumSquareCons += Math.Pow(mem.Consumption, 2);
                sumConsLevel  += (mem.Consumption * mem.LevelDeviation);
                sumConsPres   += (mem.Consumption * mem.Pressure);
                sumTemp       += mem.LevelDeviation;
                sumPres       += mem.Pressure;
            }
            double aConsTemp = (ResultData.Count * sumConsLevel - sumCons * sumTemp) / (ResultData.Count * sumSquareCons - Math.Pow(sumCons, 2));
            double bConsTemp = (sumTemp - aConsTemp * sumCons) / ResultData.Count;
            double aConsPres = (ResultData.Count * sumConsPres - sumCons * sumPres) / (ResultData.Count * sumSquareCons - Math.Pow(sumCons, 2));
            double bConsPres = (sumPres - aConsPres * sumCons) / ResultData.Count;

            foreach (var mem in approxData)
            {
                mem.LevelDeviation = mem.Consumption * aConsTemp + bConsTemp;
                mem.Pressure       = mem.Consumption * aConsPres + bConsPres;
            }
            return(approxData);
        }