Beispiel #1
0
        public void ApplyAnalysisToDataset(IExcelSheet sheet)
        {
            sheet[ExcelColumnIndex.B, 1].SetValue(ExcelStringsPhaseOnePartTwo.NormalizedColumnName);
            sheet[ExcelColumnIndex.L, 1].SetValue(ExcelStringsPhaseOnePartTwo.NormalDistributionSolutionColumnName);
            sheet.GetOrCreateCenterizedCell(ExcelColumnIndex.M, 1);

            sheet.AddMergedRegion(ExcelColumnIndex.L, 1, ExcelColumnIndex.M, 1);

            sheet[ExcelColumnIndex.L, 2].SetValue(ExcelStringsPhaseOnePartTwo.SampleMean);
            sheet[ExcelColumnIndex.L, 3].SetValue(ExcelStringsPhaseOnePartTwo.SampleVariance);
            sheet[ExcelColumnIndex.L, 4].SetValue(ExcelStringsPhaseOnePartTwo.SampleDeviation);
            sheet[ExcelColumnIndex.L, 5].SetValue(ExcelStringsPhaseOnePartTwo.VariationCoefficient);
            sheet[ExcelColumnIndex.L, 6].SetValue(ExcelStringsPhaseOnePartTwo.TheoreticalMin);
            sheet[ExcelColumnIndex.L, 7].SetValue(ExcelStringsPhaseOnePartTwo.TheoreticalMax);
            sheet[ExcelColumnIndex.L, 8].SetValue(ExcelStringsPhaseOnePartTwo.Span);
            sheet[ExcelColumnIndex.L, 9].SetValue(ExcelStringsPhaseOnePartTwo.NormalizedMean);
            sheet[ExcelColumnIndex.L, 10].SetValue(ExcelStringsPhaseOnePartTwo.NormalizedVarience);
            sheet[ExcelColumnIndex.L, 11].SetValue(ExcelStringsPhaseOnePartTwo.Alpha);
            sheet[ExcelColumnIndex.L, 12].SetValue(ExcelStringsPhaseOnePartTwo.Beta);

            string lastValueRowIndex = _args.LaunchesNumber.SkipHeader().ToString();

            sheet[ExcelColumnIndex.M, 2].SetFormula(sheet.FormulaProvider.Average($"$A$2:$A${lastValueRowIndex}"));
            sheet[ExcelColumnIndex.M, 3].SetFormula(sheet.FormulaProvider.Var($"$A$2:$A${lastValueRowIndex}"));
            sheet[ExcelColumnIndex.M, 4].SetFormula(sheet.FormulaProvider.StdDev($"$A$2:$A${lastValueRowIndex}"));
            sheet[ExcelColumnIndex.M, 5].SetFormula(ManualFormulaProvider.VariationCoefficient("$M$2", "$M$4"));
            sheet[ExcelColumnIndex.M, 6].SetFormula("$J$3");
            sheet[ExcelColumnIndex.M, 7].SetFormula("$J$5");
            sheet[ExcelColumnIndex.M, 8].SetFormula(ManualFormulaProvider.Span("$M$6", "$M$7"));
            sheet[ExcelColumnIndex.M, 9].SetFormula(sheet.FormulaProvider.Average($"$B$2:$B${lastValueRowIndex}"));
            sheet[ExcelColumnIndex.M, 10].SetFormula(sheet.FormulaProvider.Var($"$B$2:$B${lastValueRowIndex}"));
            sheet[ExcelColumnIndex.M, 11].SetFormula(ManualFormulaProvider.Alpha("$M$9", "$M$10"));
            sheet[ExcelColumnIndex.M, 12].SetFormula(ManualFormulaProvider.Beta("$M$9", "$M$10"));

            sheet.AutoSizeColumn(ExcelColumnIndex.B);
            sheet.AutoSizeColumn(ExcelColumnIndex.L);
            sheet.AutoSizeColumn(ExcelColumnIndex.M, useMergedCells: true);

            _histogramBuilder.CreateHistogramData(sheet);
        }
        private void FillStatisticalColumns(IExcelSheet sheet, ref int currentColumnIndex)
        {
            int rowIndex = 1;

            var sampleMeanColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[sampleMeanColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.SampleMeanColumnName);

            var sampleVarianceColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[sampleVarianceColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.SampleVarianceColumnName);

            var sampleDeviationColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[sampleDeviationColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.SampleDeviationColumnName);

            var normalizedMeanColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[normalizedMeanColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.NormalizedMeanColumnName);

            var normalizedVarienceColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[normalizedVarienceColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.NormalizedVarienceColumnName);

            var alphaColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[alphaColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.AlphaColumnName);

            var betaColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>();

            sheet[betaColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.BetaColumnName);

            ++rowIndex;
            int launchesColumnIndex     = 0;
            int firstRowIndex           = ExcelWrapperForPhaseTwo.GetFirstDataRowIndex();
            int lastRowIndex            = ExcelWrapperForPhaseTwo.GetLastDataRowIndex(_args);
            int firstNormalizedRowIndex = ExcelWrapperForPhaseTwo.GetFirstNormalizedDataRowIndex(_args);
            int lastNormalizedRowIndex  = ExcelWrapperForPhaseTwo.GetLastNormalizedDataRowIndex(_args);

            for (int launchesNumber = _args.StartValue; launchesNumber <= _args.EndValue;
                 launchesNumber += _args.Step)
            {
                var launchesColumnIndexEnum = launchesColumnIndex++.AsEnum <ExcelColumnIndex>();

                string dataRange =
                    $"{sheet[launchesColumnIndexEnum, firstRowIndex].Address}:" +
                    $"{sheet[launchesColumnIndexEnum, lastRowIndex].Address}";

                string sampleMeanFormula = sheet.FormulaProvider.Average(dataRange);
                sheet[sampleMeanColumnIndex, rowIndex].SetFormula(sampleMeanFormula);

                string sampleVarienceFormula = sheet.FormulaProvider.Var(dataRange);
                sheet[sampleVarianceColumnIndex, rowIndex].SetFormula(sampleVarienceFormula);

                string sampleDeviationFormula = sheet.FormulaProvider.StdDev(dataRange);
                sheet[sampleDeviationColumnIndex, rowIndex].SetFormula(sampleDeviationFormula);

                string normalizedDataRange =
                    $"{sheet[launchesColumnIndexEnum, firstNormalizedRowIndex].Address}:" +
                    $"{sheet[launchesColumnIndexEnum, lastNormalizedRowIndex].Address}";

                string normalizedMeanFormula = sheet.FormulaProvider.Average(normalizedDataRange);
                sheet[normalizedMeanColumnIndex, rowIndex].SetFormula(normalizedMeanFormula);

                string normalizedVarienceFormula = sheet.FormulaProvider.Var(normalizedDataRange);
                sheet[normalizedVarienceColumnIndex, rowIndex].SetFormula(normalizedVarienceFormula);

                string normalizedMeanAddress     = sheet[normalizedMeanColumnIndex, rowIndex].Address;
                string normalizedVarienceAddress = sheet[normalizedVarienceColumnIndex, rowIndex].Address;

                string alphaFormula = ManualFormulaProvider.Alpha(
                    normalizedMeanAddress, normalizedVarienceAddress
                    );
                sheet[alphaColumnIndex, rowIndex].SetFormula(alphaFormula);

                string betaFormula = ManualFormulaProvider.Beta(
                    normalizedMeanAddress, normalizedVarienceAddress
                    );
                sheet[betaColumnIndex, rowIndex].SetFormula(betaFormula);

                ++rowIndex;
            }

            sheet.AutoSizeColumn(sampleMeanColumnIndex);
            sheet.AutoSizeColumn(sampleVarianceColumnIndex);
            sheet.AutoSizeColumn(sampleDeviationColumnIndex);
            sheet.AutoSizeColumn(normalizedMeanColumnIndex);
            sheet.AutoSizeColumn(normalizedVarienceColumnIndex);
            sheet.AutoSizeColumn(alphaColumnIndex);
            sheet.AutoSizeColumn(betaColumnIndex);
        }