Example #1
0
        private void ShowQuantitiveOnGrid(DataGridView dataGridView, QuantitiveCharacteristics quantChar)
        {
            dataGridView.Rows[0].Cells[0].Value = Math.Round(quantChar.arithmeticMean.value, 6).ToString();
            dataGridView.Rows[1].Cells[0].Value = Math.Round(quantChar.median.value, 6).ToString();
            dataGridView.Rows[2].Cells[0].Value = Math.Round(Math.Sqrt(quantChar.variance.value), 6).ToString();
            dataGridView.Rows[3].Cells[0].Value = Math.Round(quantChar.skewness.value, 6).ToString();
            dataGridView.Rows[4].Cells[0].Value = Math.Round(quantChar.kurtosis.value, 6).ToString();
            dataGridView.Rows[5].Cells[0].Value = Math.Round(quantChar.variationsCoef.value, 6).ToString();

            dataGridView.Rows[0].Cells[1].Value = Math.Round(quantChar.arithmeticMean.standardDeviation, 6).ToString();
            dataGridView.Rows[1].Cells[1].Value = "-";
            dataGridView.Rows[2].Cells[1].Value = Math.Round(quantChar.variance.standardDeviation, 6).ToString();
            dataGridView.Rows[3].Cells[1].Value = Math.Round(quantChar.skewness.standardDeviation, 6).ToString();
            dataGridView.Rows[4].Cells[1].Value = Math.Round(quantChar.kurtosis.standardDeviation, 6).ToString();
            dataGridView.Rows[5].Cells[1].Value = Math.Round(quantChar.variationsCoef.standardDeviation, 6).ToString();

            dataGridView.Rows[0].Cells[2].Value = "[" + Math.Round(quantChar.arithmeticMean.confidenceInterval.min, 6).ToString() + "; " +
                                                                           Math.Round(quantChar.arithmeticMean.confidenceInterval.max, 6).ToString() + "]";
            dataGridView.Rows[1].Cells[2].Value = "-";
            dataGridView.Rows[2].Cells[2].Value = "[" + Math.Round(quantChar.variance.confidenceInterval.min, 6).ToString() + "; " +
                                                                           Math.Round(quantChar.variance.confidenceInterval.max, 6).ToString() + "]";
            dataGridView.Rows[3].Cells[2].Value = "[" + Math.Round(quantChar.skewness.confidenceInterval.min, 6).ToString() + "; " +
                                                                           Math.Round(quantChar.skewness.confidenceInterval.max, 6).ToString() + "]";
            dataGridView.Rows[4].Cells[2].Value = "[" + Math.Round(quantChar.kurtosis.confidenceInterval.min, 6).ToString() + "; " +
                                                                           Math.Round(quantChar.kurtosis.confidenceInterval.max, 6).ToString() + "]";
            dataGridView.Rows[5].Cells[2].Value = "[" + Math.Round(quantChar.variationsCoef.confidenceInterval.min, 6).ToString() + "; " +
                                                                           Math.Round(quantChar.variationsCoef.confidenceInterval.max, 6).ToString() + "]";
        }
Example #2
0
        public QuantitiveCharacteristics CalculateQuantitiveCharacteristics(List<double> paramData, double alpha)
        {
            QuantitiveCharacteristics result = new QuantitiveCharacteristics();
            List<double> data = new List<double>();
            double sum_arMean, sum_varianse, sum_varianse2, sum_skewness, sum_kurtosis;
            double _v, _a, _e;
            double quantil;

            foreach (double element in paramData)
            {
                data.Add(element);
            }
            
            data.Sort();
            sum_arMean = sum_varianse = sum_varianse2 = sum_skewness = sum_kurtosis = 0;

            /// VALUES \\\
            foreach (double item in data)
            {
                sum_arMean += item;
            }
            result.arithmeticMean.value = sum_arMean / data.Count;

            if ((data.Count % 2) == 1)
            {
                result.median.value = data[data.Count / 2];
            }
            else
            {
                result.median.value = (data[data.Count / 2] + data[(data.Count / 2) - 1]) / 2.0;
            }

            foreach (double item in data)
            {
                sum_varianse += Math.Pow((item - result.arithmeticMean.value), 2);
                sum_varianse2 += Math.Pow(item, 2) - Math.Pow(result.arithmeticMean.value, 2);
                sum_skewness += Math.Pow((item - result.arithmeticMean.value), 3);
                sum_kurtosis += Math.Pow((item - result.arithmeticMean.value), 4);
            }

            _v = sum_varianse2 / data.Count;
            _a = sum_skewness / (data.Count * Math.Pow(_v, 3.0 / 2.0));
            _e = sum_kurtosis / (data.Count * Math.Pow(_v, 2));

            result.variance.value = sum_varianse / (data.Count - 1);
            result.skewness.value = _a * (Math.Sqrt(data.Count * (data.Count - 1)) / (data.Count - 2));

            result.kurtosis.value = ((Math.Pow(data.Count, 2.0) - 1) / ((data.Count - 2) * (data.Count - 3))) * ((_e - 3) + (6 / (data.Count + 1)));

            result.variationsCoef.value = Math.Sqrt(result.variance.value) / result.arithmeticMean.value;


            /// Deviations \\\
            result.arithmeticMean.standardDeviation = Math.Sqrt(result.variance.value / (double)data.Count);
            result.variance.standardDeviation = Math.Sqrt(result.variance.value / (2.0 * (double)data.Count));
            result.skewness.standardDeviation = Math.Sqrt((6.0 * ((double)data.Count - 2.0)) / (((double)data.Count + 1.0) * ((double)data.Count + 3.0)));
            result.kurtosis.standardDeviation = Math.Sqrt(((24.0 * (double)data.Count) * ((double)data.Count - 2.0) * ((double)data.Count - 3.0)) /
                                                           (((double)data.Count + 1.0) * ((double)data.Count + 1.0) * ((double)data.Count + 3.0) * ((double)data.Count + 5.0)));
            result.variationsCoef.standardDeviation = result.variationsCoef.value * Math.Sqrt((1 + (2.0 * Math.Pow(result.variationsCoef.value, 2))) / (2.0 * (double)data.Count));


            /// Intervals \\\
            quantil = QuantilCalculator.StudentQuantil((1.0 - (alpha / 2)), (data.Count - 1));

            result.arithmeticMean.confidenceInterval.min = result.arithmeticMean.value - (quantil * result.arithmeticMean.standardDeviation);
            result.arithmeticMean.confidenceInterval.max = result.arithmeticMean.value + (quantil * result.arithmeticMean.standardDeviation);

            result.variance.confidenceInterval.min = Math.Sqrt(result.variance.value) - (quantil * result.variance.standardDeviation);
            result.variance.confidenceInterval.max = Math.Sqrt(result.variance.value) + (quantil * result.variance.standardDeviation);

            result.skewness.confidenceInterval.min = result.skewness.value - (quantil * result.skewness.standardDeviation);
            result.skewness.confidenceInterval.max = result.skewness.value + (quantil * result.skewness.standardDeviation);

            result.kurtosis.confidenceInterval.min = result.kurtosis.value - (quantil * result.kurtosis.standardDeviation);
            result.kurtosis.confidenceInterval.max = result.kurtosis.value + (quantil * result.kurtosis.standardDeviation);

            result.variationsCoef.confidenceInterval.min = result.variationsCoef.value - (quantil * result.variationsCoef.standardDeviation);
            result.variationsCoef.confidenceInterval.max = result.variationsCoef.value + (quantil * result.variationsCoef.standardDeviation);

            return (result);
        }