public AnalysisPhaseTwo(LocalFileWorker fileWorker) { _fileWorker = fileWorker.ThrowIfNull(nameof(fileWorker)); _excelWrapperForPhaseTwo = new ExcelWrapperForPhaseTwo(); _asyncLock = new AsyncLock(); }
public BetaDistributionAnalysisPhaseTwo(ParametersPack args, IRegression regression) { _args = args.ThrowIfNull(nameof(args)); _regression = regression.ThrowIfNull(nameof(regression)); _iterationsNumber = args.GetIterationsNumber(phaseNumber: 2); _lastSegmentValueRowIndex = _iterationsNumber.SkipHeader(); _additionalDataColumn = ExcelWrapperForPhaseTwo.GetAdditionalDataColumn(_iterationsNumber); _sampleSizeColumnIndex = ExcelWrapperForPhaseTwo.GetSampleSizeColumn(_iterationsNumber); _theoreticalMinColumn = ExcelWrapperForPhaseTwo.GetTheoreticalMinColumn(_iterationsNumber); _theoreticalMaxColumn = ExcelWrapperForPhaseTwo.GetTheoreticalMaxColumn(_iterationsNumber); _alphaColumn = GetAlphaColumn(); _betaColumn = GetBetaColumn(); }
public void ApplyAnalysisToSingleLaunch(IExcelSheet sheet, ExcelColumnIndex currentColumn, int currentRow, int operationNumber) { string dataAddress = sheet[currentColumn, currentRow].Address; int theoreticalDataRow = currentColumn.AsInt32().UseOneBasedIndexing().SkipHeader(); string theoreticalMinAddress = sheet[_theoreticalMinColumn, theoreticalDataRow].Address; string theoreticalMaxAddress = sheet[_theoreticalMaxColumn, theoreticalDataRow].Address; string normalizedFormula = ManualFormulaProvider.Normalize( dataAddress, theoreticalMinAddress, theoreticalMaxAddress ); int normalizedDataRowIndex = ExcelWrapperForPhaseTwo.GetNormalizedDataRowIndex( _args, currentRow ); sheet[currentColumn, normalizedDataRowIndex].SetFormula(normalizedFormula); }
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); }