CalculateCoefficientOfDetermination(IModelledFunction modelledFunction, IEnumerable <double> observedValues) { double coefficientOfDetermination = GoodnessOfFit.CoefficientOfDetermination( observedValues, modelledFunction.Calculate(observedValues) ); return(modelledFunction, coefficientOfDetermination); }
CalculateRSquaredValue(IModelledFunction modelledFunction, IEnumerable <double> observedValues) { double rSquaredValue = GoodnessOfFit.RSquared( observedValues, modelledFunction.Calculate(observedValues) ); return(modelledFunction, rSquaredValue); }
private void FillAnalysisColumns(IExcelSheet sheet, ref int currentColumnIndex) { int rowIndex = 1; var nColumnColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[nColumnColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.NColumnName); var alphaNColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[alphaNColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.AlphaNColumnName); var betaNColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[betaNColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.BetaNColumnName); var analysisValuesColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[analysisValuesColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.AnalysisValuesColumnName); // Remain blank column. ++currentColumnIndex; var leftYQuantileColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[leftYQuantileColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.LeftYQuantileColumnName); var complexityFunctionColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[complexityFunctionColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.ComplexityFunctionColumnName); var comparisonColumnIndex = currentColumnIndex.AsEnum <ExcelColumnIndex>(); sheet[comparisonColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.ComparisonColumnName); IExcelCellHolder confidenceFactorCell = GetConfidenceFactorCell(sheet); IModelledFunction alphaOptimalFunction = GetOptimalFunction(sheet, _alphaColumn); string formulaForAlphaFunction = ManualFormulaProvider.GetFormulaForFunction( sheet.FormulaProvider, alphaOptimalFunction.Type ); IModelledFunction betaOptimalFunction = GetOptimalFunction(sheet, _betaColumn); string formulaForBetaFunction = ManualFormulaProvider.GetFormulaForFunction( sheet.FormulaProvider, betaOptimalFunction.Type ); ++rowIndex; for (int launchesNumber = _args.StartValue; launchesNumber <= _args.ExtrapolationSegmentValue; launchesNumber += _args.Step) { IExcelCellHolder nColumnCell = sheet[nColumnColumnIndex, rowIndex]; nColumnCell.SetValue(launchesNumber); string alphaNFormula = alphaOptimalFunction.ToFormulaString( nColumnCell.Address, formulaForAlphaFunction ); IExcelCellHolder alphaNCell = sheet[alphaNColumnIndex, rowIndex]; alphaNCell.SetFormula(alphaNFormula); string betaNFormula = betaOptimalFunction.ToFormulaString( nColumnCell.Address, formulaForBetaFunction ); IExcelCellHolder betaNCell = sheet[betaNColumnIndex, rowIndex]; betaNCell.SetFormula(betaNFormula); string leftYQuantileFormula = sheet.FormulaProvider.BetaInv( confidenceFactorCell.Address, alphaNCell.Address, betaNCell.Address ); IExcelCellHolder leftYQuantileCell = sheet[leftYQuantileColumnIndex, rowIndex]; leftYQuantileCell.SetFormula(leftYQuantileFormula); string theoreticalMinAddress = sheet[_theoreticalMinColumn, rowIndex].Address; string theoreticalMaxAddress = sheet[_theoreticalMaxColumn, rowIndex].Address; string complexityFunctionFormula = ManualFormulaProvider.ConfidenceComplexity( leftYQuantileCell.Address, theoreticalMinAddress, theoreticalMaxAddress ); IExcelCellHolder complexityCell = sheet[complexityFunctionColumnIndex, rowIndex]; complexityCell.SetFormula(complexityFunctionFormula); string comparisonFormula = $"{theoreticalMaxAddress} / {complexityCell.Address}"; sheet[comparisonColumnIndex, rowIndex].SetFormula(comparisonFormula); ++rowIndex; } string alphaPearsonFormula = sheet.FormulaProvider.Pearson( $"{sheet[_alphaColumn, 2].Address}:" + $"{sheet[_alphaColumn, _lastSegmentValueRowIndex].Address}", $"{sheet[alphaNColumnIndex, 2].Address}:" + $"{sheet[alphaNColumnIndex, _lastSegmentValueRowIndex].Address}" ); sheet[analysisValuesColumnIndex, 2].SetFormula(alphaPearsonFormula); string betaPearsonFormula = sheet.FormulaProvider.Pearson( $"{sheet[_betaColumn, 2].Address}:" + $"{sheet[_betaColumn, _lastSegmentValueRowIndex].Address}", $"{sheet[betaNColumnIndex, 2].Address}:" + $"{sheet[betaNColumnIndex, _lastSegmentValueRowIndex].Address}" ); sheet[analysisValuesColumnIndex, 3].SetFormula(betaPearsonFormula); sheet.AutoSizeColumn(nColumnColumnIndex); sheet.AutoSizeColumn(alphaNColumnIndex); sheet.AutoSizeColumn(betaNColumnIndex); sheet.AutoSizeColumn(analysisValuesColumnIndex); sheet.AutoSizeColumn(leftYQuantileColumnIndex); sheet.AutoSizeColumn(complexityFunctionColumnIndex); sheet.AutoSizeColumn(comparisonColumnIndex); }