Esempio n. 1
0
        public void AddValues()
        {
            if (_currentMode == 0)
            {
                _currentQuantity++;

                XAxis.Add(_currentQuantity.ToString());

                if (XAxis.Count > 60)
                {
                    XAxisGap = 3;
                }
                else if (XAxis.Count > 40)
                {
                    XAxisGap = 2;
                }
                else if (XAxis.Count > 20)
                {
                    XAxisGap = 1;
                }

                var value = GetRandomDecimal1();
                Points.Add(new PUChartPoint()
                {
                    Value    = value,
                    ValueTip = (value * 10).ToString("f2"),
                });
            }
        }
Esempio n. 2
0
        private void CalculateRegression()
        {
            var x = Vector.Create(ChartValues.Select(v => v.NDouble).ToArray());
            var y = Vector.Create(ChartValues.Select(v => v.TotDouble).ToArray());

            _regression = new SimpleRegressionModel(y, x);
            _regression.Fit();

            UpperValues.Clear();
            LowerValues.Clear();
            RegressionValues.Clear();
            NToNValues.Clear();
            XAxis.Clear();
            YAxis.Clear();

            var max = ChartValues.Max(p => p.NDouble);

            XAxis.Add(new ObservablePoint(0, 0));
            XAxis.Add(new ObservablePoint(0, max));
            YAxis.Add(new ObservablePoint(0, 0));
            YAxis.Add(new ObservablePoint(max, 0));



            NToNValues.Add(new ObservablePoint(0, 0));
            NToNValues.Add(new ObservablePoint(max, max));

            var ci = _regression.GetPredictionInterval(0, .99);

            UpperValues.Add(new ObservablePoint(0, ci.UpperBound));
            LowerValues.Add(new ObservablePoint(0, ci.LowerBound));
            RegressionValues.Add(new ObservablePoint(0, ci.Center));

            ci = _regression.GetPredictionInterval(max, .99);
            UpperValues.Add(new ObservablePoint(max, ci.UpperBound));
            LowerValues.Add(new ObservablePoint(max, ci.LowerBound));
            RegressionValues.Add(new ObservablePoint(max, ci.Center));

            var above = 0.0;
            var below = 0.0;

            foreach (var point in ChartValues)
            {
                var interval = _regression.GetPredictionInterval(point.NDouble, .99);
                if (point.TotDouble <= interval.UpperBound && point.TotDouble > interval.Center)
                {
                    above++;
                }
                else if (point.TotDouble <= interval.Center && point.TotDouble >= interval.LowerBound)
                {
                    below++;
                }
            }
            Console.WriteLine("Above Center: " + above / ChartValues.Count);
            Console.WriteLine("Below Center: " + below / ChartValues.Count);
        }