コード例 #1
0
 private void CalculateInterval()
 {
     this._intervals = new BarChartInterval[_intervalsCount];
     double min = _distribution.GetSampling().Min();
     double max = _distribution.GetSampling().Max();
     double intervalLength = (max - min) / _intervalsCount;
     BarChartInterval interval = new BarChartInterval();
     for (int j = 0; j < _intervals.Length; j++)
     {
         interval.Frequence = (int)CalculateFrequency();
         _intervals[j] = interval;
     }
 }
コード例 #2
0
ファイル: MainModel.cs プロジェクト: loner7543/NIRProject
        public void ReadFile()
        {
            StreamReader sr = new StreamReader(@Path2);
            int intervalsCount = Int32.Parse(sr.ReadLine());
            BarChartInterval[] intervals = new BarChartInterval[intervalsCount];
            for (int i = 0; i < intervals.Length; i++)
            {
                BarChartInterval currentInterval = new BarChartInterval();
                currentInterval.Frequence = Int32.Parse(sr.ReadLine());
                currentInterval.LeftBorder = Double.Parse(sr.ReadLine());
                currentInterval.RightBorder = Double.Parse(sr.ReadLine());
                currentInterval.Length = Double.Parse(sr.ReadLine());
                intervals[i] = currentInterval;

            }
            _barChart.Intervals = intervals;

        }
コード例 #3
0
        /// <summary>
        /// Рассчитывает массив интервалов  разбиения 
        /// </summary>
        private void CalculateIntervals()
        {
            this._intervals = new BarChartInterval[_intervalsCount];

            double min = _distribution.GetSampling().Min();
            double max = _distribution.GetSampling().Max();

            double intervalLength = (max - min) / _intervalsCount;

            BarChartInterval interval = null;

            double leftBorder;
            double rightBorder;

            for (int i = 0; i < _intervals.Length; i++)
            {
                leftBorder = min + intervalLength * i;
                rightBorder = i == _intervals.Length - 1 ? max : min + intervalLength * (i + 1);//либо внутри гистограммы, либо является квайним правым интервалом 

                interval = new BarChartInterval()
                {
                    LeftBorder = leftBorder,
                    RightBorder = rightBorder,
                    Frequence = _distribution.GetSampling().Where(s => s >= leftBorder && s < rightBorder).Count(),
                    Length = intervalLength
                };

                _intervals[i] = interval;
            }
        }