mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 23:59:19 +02:00
TAChart: Fix crash of fitdemo to polygon when DOF=0
git-svn-id: trunk@63613 -
This commit is contained in:
parent
28d7ea6732
commit
818b9a1eed
@ -98,7 +98,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(aFitResults: TFitResults; aAlpha: Double = 0.05);
|
constructor Create(aFitResults: TFitResults; aAlpha: Double = 0.05);
|
||||||
procedure Report_ANOVA(AText: TStrings; ASeparator: String = ': ';
|
procedure Report_ANOVA(AText: TStrings; ASeparator: String = ': ';
|
||||||
ANumFormat: String = '%f');
|
ANumFormat: String = '%f'; AExpFormat: String = '%.3e'; NaNStr: String = 'n/a');
|
||||||
procedure Report_VarCovar(AText: TSTrings; ANumFormat: String = '%12.6f');
|
procedure Report_VarCovar(AText: TSTrings; ANumFormat: String = '%12.6f');
|
||||||
public
|
public
|
||||||
function AdjR2: Double;
|
function AdjR2: Double;
|
||||||
@ -430,7 +430,10 @@ end;
|
|||||||
parameters. Should be close to 1 ("good" fit). "0" means: "poor" fit }
|
parameters. Should be close to 1 ("good" fit). "0" means: "poor" fit }
|
||||||
function TFitStatistics.AdjR2: Double;
|
function TFitStatistics.AdjR2: Double;
|
||||||
begin
|
begin
|
||||||
Result := 1.0 - (1.0 - R2) * (N - 1) / DOF;
|
if DOF > 0 then
|
||||||
|
Result := 1.0 - (1.0 - R2) * (N - 1) / DOF
|
||||||
|
else
|
||||||
|
Result := NaN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFitStatistics.CalcTValue;
|
procedure TFitStatistics.CalcTValue;
|
||||||
@ -524,34 +527,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFitStatistics.Report_ANOVA(AText: TStrings; ASeparator: String = ': ';
|
procedure TFitStatistics.Report_ANOVA(AText: TStrings; ASeparator: String = ': ';
|
||||||
ANumFormat: String = '%f');
|
ANumFormat: String = '%f'; AExpFormat: String = '%.3e'; NaNStr: String = 'n/a');
|
||||||
const
|
const
|
||||||
FMT = '%.3e';
|
PRECISION = 3;
|
||||||
begin
|
begin
|
||||||
AText.Add(rsFitNumObservations + ASeparator + IntToStr(N));
|
AText.Add(rsFitNumObservations + ASeparator + IntToStr(N));
|
||||||
AText.Add(rsFitNumFitParams + ASeparator + IntToStr(M));
|
AText.Add(rsFitNumFitParams + ASeparator + IntToStr(M));
|
||||||
AText.Add(rsFitDegreesOfFreedom + ASeparator + IntToStr(DOF));
|
AText.Add(rsFitDegreesOfFreedom + ASeparator + IntToStr(DOF));
|
||||||
AText.Add(rsFitTotalSumOfSquares + ASeparator +
|
AText.Add(rsFitTotalSumOfSquares + ASeparator + FloatToStrEx(SST, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
Format(IfThen(SST > 1E6, FMT, ANumFormat), [SST]));
|
AText.Add(rsFitRegressionSumOfSquares + ASeparator + FloatToStrEx(SSR, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
AText.Add(rsFitRegressionSumOfSquares + ASeparator +
|
AText.Add(rsFitErrorSumOfSquares + ASeparator + FloatToStrEx(SSE, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
Format(IfThen(SST > 1E6, FMT, ANumFormat), [SSR]));
|
AText.Add(rsFitCoefficientOfDetermination + ASeparator + FloatToStrEx(R2, PRECISION, ANumFormat, '', NaNStr));
|
||||||
AText.Add(rsFitErrorSumOfSquares + ASeparator +
|
AText.Add(rsFitAdjCoefficientOfDetermination + ASeparator + FloatToStrEx(AdjR2, PRECISION, ANumFormat, '', NaNStr));
|
||||||
Format(ifThen(SST > 1E6, FMT, ANumFormat), [SSE]));
|
AText.Add(rsFitChiSquared + ASeparator + FloatToStrEx(Chi2, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
AText.Add(rsFitCoefficientOfDetermination + ASeparator + Format(ANumFormat, [R2]));
|
AText.Add(rsFitReducedChiSquared + ASeparator + FloatToStrEx(ReducedChi2, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
AText.Add(rsFitAdjCoefficientOfDetermination + ASeparator + Format(ANumFormat, [AdjR2]));
|
AText.Add(rsFitResidualStandardError + ASeparator + FloatToStrEx(ResidualStdError, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
AText.Add(rsFitChiSquared + ASeparator + Format(ANumFormat, [Chi2]));
|
AText.Add(rsFitVarianceRatio + ASeparator + FloatToStrEx(F, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
AText.Add(rsFitReducedChiSquared + ASeparator + Format(ANumFormat, [ReducedChi2]));
|
|
||||||
AText.Add(rsFitResidualStandardError + ASeparator + Format(ANumFormat, [ResidualStdError]));
|
|
||||||
AText.Add(rsFitVarianceRatio + ASeparator + Format(ANumFormat, [F]));
|
|
||||||
{
|
{
|
||||||
AText.Add(Format('Fcrit(%d, %d)', [M-1, DOF]) + ASeparator +
|
AText.Add(Format('Fcrit(%d, %d)', [M-1, DOF]) + ASeparator +
|
||||||
Format(IfThen(Fcrit < 1E-3, FMT, ANumFormat), [Fcrit]));
|
Format(IfThen(Fcrit < 1E-3, FMT, ANumFormat), [Fcrit]));
|
||||||
}
|
}
|
||||||
{$IF FPC_FullVersion >= 30004}
|
{$IF FPC_FullVersion >= 30004}
|
||||||
AText.Add(rsFitTValue + ASeparator +
|
AText.Add(rsFitTValue + ASeparator + FloatToStrEx(FtValue, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
Format(IfThen(FtValue < 1E-3, '%.3e', ANumFormat), [FtValue]));
|
AText.Add(rsFitPValue + ASeparator + FloatToStrEx(pValue, PRECISION, ANumFormat, AExpFormat, NaNStr));
|
||||||
AText.Add(rsFitPValue + ASeparator +
|
|
||||||
Format(IfThen(pValue < 1E-3, '%.3e', ANumFormat), [pValue]));
|
|
||||||
{$IFEND}
|
{$IFEND}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user