Пример #1
0
        protected override List <double> probabilitiesCount(IntervalVariationStatisticSeries intervalSeries)
        {
            // Рассчитанные вероятности
            List <double> probabilities = new List <double>();
            double        firstArg = 0, secondArg = 0;
            int           i = 0;

            foreach (KeyValuePair <LinearInterval, double> pair in intervalSeries.SeriesTable)
            {
                if (i == 0)
                {   // Левая граница последовательности инетрвалов (-inf)
                    secondArg = -5;
                    firstArg  = pair.Key.RightBorder;
                }
                else if (i == intervalSeries.SeriesTable.Count - 1)
                {   // Правая граница последовательности инетрвалов (+inf)
                    firstArg  = 5;
                    secondArg = pair.Key.LeftBorder;
                }
                else
                {
                    firstArg  = pair.Key.RightBorder;
                    secondArg = pair.Key.LeftBorder;
                }
                //if (secondArg < 0)
                //   probabilities.Add(Math.Round(getLaplasFunctionValue(secondArg) - getLaplasFunctionValue(firstArg), 3));
                //else if(firstArg < 0)
                probabilities.Add(Math.Round(getLaplasFunctionValue(firstArg) - getLaplasFunctionValue(secondArg), 3));

                i++;
            }
            return(probabilities);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SortedDictionary <LinearInterval, double> intervalSeriesTable = new SortedDictionary <LinearInterval, double>();
            int index         = 0;
            int stringCounter = 0;

            try
            {
                String currentString = getNextString(sourceIntervalSeriesBox.Text, ref index);
                stringCounter++;
                while (currentString != "")
                {
                    getLinearIntervalDoublePairFromString(currentString);
                    intervalSeriesTable.Add(lastReadedInterval, lastCount);
                    currentString = getNextString(sourceIntervalSeriesBox.Text, ref index);
                    stringCounter++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Не верно записан ряд. Заполняйте поле ввода согласно стандарту.");
                return;
            }
            finally
            {
                intSeries = IntervalVariationStatisticSeries.calculateSeriesFromReadySeries(intervalSeriesTable);
            }
        }
Пример #3
0
        public static IntervalVariationStatisticSeries calculateSeriesFromReadySeries(SortedDictionary <LinearInterval, double> series)
        {
            IntervalVariationStatisticSeries currentSeries = new IntervalVariationStatisticSeries();

            currentSeries.varSeries = null;
            currentSeries.table     = series;
            return(currentSeries);
        }
Пример #4
0
        public static IntervalVariationStatisticSeries calculateSeriesFromVariationSeriesAndIntervalLength(VariationSeries varSeries, int intervalsCount)
        {
            IntervalVariationStatisticSeries currentSeries = new IntervalVariationStatisticSeries();

            currentSeries.varSeries = varSeries;
            currentSeries.calculateDeltaInterval(intervalsCount);
            currentSeries.addIntervalsWithValues(intervalsCount);
            return(currentSeries);
        }
Пример #5
0
        public static GroupedRelativeArequenceSeries calculateFromIntervalSeries(IntervalVariationStatisticSeries intSeries, int intervalsCount)
        {
            GroupedRelativeArequenceSeries currentSeries = new GroupedRelativeArequenceSeries();

            currentSeries.varSeries      = null;
            currentSeries.intervalSeries = intSeries;
            currentSeries.calculateElementsCount();
            currentSeries.addElementsToTable();
            return(currentSeries);
        }
Пример #6
0
        protected override double countHiObserved(IntervalVariationStatisticSeries intSeries)
        {
            double hiObserved = 0;
            double theoryFreq;
            int    i = 0;

            foreach (KeyValuePair <LinearInterval, double> pair in intSeries.SeriesTable)
            {
                theoryFreq  = intSeries.SeriesTableFreqSum * probabilities[i];
                hiObserved += Math.Pow(pair.Value - theoryFreq, 2) / theoryFreq;
                i++;
            }
            return(hiObserved);
        }
Пример #7
0
        protected override List <double> probabilitiesCount(IntervalVariationStatisticSeries inValue)
        {
            List <double> probs = new List <double>();    // Вероятности
            GroupedRelativeArequenceSeries groupedSeries = GroupedRelativeArequenceSeries.calculateFromIntervalSeries(inValue, inValue.SeriesTable.Count);
            double sampleMean = SeriesCharacteristics.calculateSampleMean(groupedSeries.SeriesTable);
            double lambda     = 1 / sampleMean;
            double buff;

            foreach (KeyValuePair <LinearInterval, double> pair in inValue.SeriesTable)
            {
                buff = Math.Exp(-lambda * pair.Key.LeftBorder) - Math.Exp(-lambda * pair.Key.RightBorder);
                probs.Add(buff);
            }
            return(probs);
        }
Пример #8
0
        private IntervalVariationStatisticSeries createNewIntervalSeries(IntervalVariationStatisticSeries old)
        {
            GroupedRelativeArequenceSeries groupedSeries = GroupedRelativeArequenceSeries.calculateFromIntervalSeries(old, old.SeriesTable.Count);
            double sampleMean       = SeriesCharacteristics.calculateSampleMean(groupedSeries.SeriesTable);
            double sampleMeanSquare = SeriesCharacteristics.calculateSampleMeanSquare(groupedSeries.SeriesTable);
            IntervalVariationStatisticSeries newInterval = IntervalVariationStatisticSeries.calculateSeriesFromReadySeries(old.SeriesTable);

            foreach (KeyValuePair <LinearInterval, double> pair in newInterval.SeriesTable)
            {
                pair.Key.LeftBorder  = (pair.Key.LeftBorder - sampleMean) / sampleMeanSquare;
                pair.Key.RightBorder = (pair.Key.RightBorder - sampleMean) / sampleMeanSquare;
            }

            return(newInterval);
        }
Пример #9
0
        protected override double countHiObserved(IntervalVariationStatisticSeries intSeries)
        {
            double sum = 0;
            double numerator, denomirator;
            int    i = 0;

            foreach (KeyValuePair <LinearInterval, double> pair in intSeries.SeriesTable)
            {
                double toPow = pair.Value - intSeries.SeriesTableFreqSum * probabilities[i];
                numerator   = Math.Pow(toPow, 2);
                denomirator = intSeries.SeriesTableFreqSum * probabilities[i];
                sum        += numerator / denomirator;
                i++;
            }
            return(sum);
        }
Пример #10
0
        private void readIntervalsGrid()
        {
            SortedDictionary <LinearInterval, double> intervalSeriesTable = new SortedDictionary <LinearInterval, double>();
            // Считать ряд из таблицы
            LinearInterval bufInterval;
            double         leftBorder, rightBorder, freq;

            for (int i = 0; i < dgvIntervals.Rows.Count; i++)
            {
                leftBorder  = Convert.ToDouble(dgvIntervals.Rows[i].Cells[0].Value);
                rightBorder = Convert.ToDouble(dgvIntervals.Rows[i].Cells[1].Value);
                freq        = Convert.ToDouble(dgvIntervals.Rows[i].Cells[2].Value);
                bufInterval = new LinearInterval(leftBorder, rightBorder);
                intervalSeriesTable.Add(bufInterval, freq);
            }
            // Получить интервальные ряды
            intSeries = IntervalVariationStatisticSeries.calculateSeriesFromReadySeries(intervalSeriesTable);
        }
Пример #11
0
        public override bool doCheck(double significanceLevel, IntervalVariationStatisticSeries intSeries)
        {
            bool   lawConfirmed = true;
            double k            = intSeries.SeriesTable.Count - 2;

            // Рассчитать вероятности
            probabilities = probabilitiesCount(intSeries);
            // Рассчитать наблюдаемое значение критерия Хи квадрат
            hiObserved = countHiObserved(intSeries);
            hiCritical = findHiCritical(k, significanceLevel);
            if (hiObserved <= hiCritical)
            {
                lawConfirmed = true;
            }
            else
            {
                lawConfirmed = false;
            }
            return(lawConfirmed);
        }
Пример #12
0
        public override bool doCheck(double significanceLevel, IntervalVariationStatisticSeries intSeries)
        {
            bool   lawConfirmed = true;                            // Подтверждение закона
            double k            = intSeries.SeriesTable.Count - 3; // Количество степеней свободы
            // Сформировать новый интервальный ряд
            IntervalVariationStatisticSeries newInterval = createNewIntervalSeries(intSeries);

            // Рассчитать вероятности
            probabilities = probabilitiesCount(newInterval);
            // Рассчитать наблюдаемое значение критерия Хи квадрат
            hiObserved = countHiObserved(newInterval);
            // Найти критическую точку в таблице Хи квадрат
            hiCritical = findHiCritical(k, significanceLevel);
            if (hiObserved <= hiCritical)
            {
                lawConfirmed = true;
            }
            else
            {
                lawConfirmed = false;
            }
            return(lawConfirmed);
        }
Пример #13
0
 private void fillTable()
 {
     if (SourceValues.valuesTable != null)
     {
         variationSeries       = VariationSeries.calculateSerires();
         relativeSeries        = variationSeries.getRelativeSeries();
         intervalSeries        = variationSeries.getIntervalVariationSeries((int)intervalsCountUpDown.Value);
         groupedRelativeSeries = variationSeries.getGroupedRelativeArequenceSeries((int)intervalsCountUpDown.Value);
         calculated            = true;
         printTable();
     }
     else
     {
         string errMsg = "Необходимо загрузить выборку из файла. Выберите файл с выборкой.";
         MessageBox.Show(errMsg, "Внимание");
         LoggerEvs.writeLog(errMsg);
         LoggerEvs.writeLog("Открытие входной выборки...");
         if (openDataInputFile())
         {
             LoggerEvs.writeLog("Входная выборка успешно открыта!");
             fillTable();
         }
     }
 }
Пример #14
0
 /// <summary>
 /// Рассчитать наблюдаемое значение Хи квадрат
 /// </summary>
 /// <param name="intSeries">Интервальный ряд частот</param>
 /// <returns>Хи квадрат наблюдаемое</returns>
 abstract protected double countHiObserved(IntervalVariationStatisticSeries intSeries);
Пример #15
0
 /// <summary>
 /// Рассчитать вероятности
 /// </summary>
 /// <param name="inValue">Интервальный ряд</param>
 /// <returns>Коллекция вероятностей</returns>
 abstract protected List <double> probabilitiesCount(IntervalVariationStatisticSeries inValue);
Пример #16
0
 /// <summary>
 /// Выполнить проверку гипотезы
 /// </summary>
 /// <param name="significanceLevel">Уровень значимости</param>
 /// <param name="intSeries">Интервальный ряд</param>
 /// <returns>Подтверждение гипотезы</returns>
 abstract public bool doCheck(double significanceLevel, IntervalVariationStatisticSeries intSeries);
Пример #17
0
 /// <summary>
 /// Создает интервальный ряд статистический, исходя из данных, расчитанных в текущем объекте.
 /// </summary>
 /// <param name="intervalsCount">Количество интервалов разбиения.</param>
 /// <returns>Интервальный статисический ряд частот.</returns>
 public IntervalVariationStatisticSeries getIntervalVariationSeries(int intervalsCount)
 {
     return(IntervalVariationStatisticSeries.calculateSeriesFromVariationSeriesAndIntervalLength(this, intervalsCount));
 }