mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 20:18:14 +02:00
TAChart: Add fit parameter confidence limits to FitSeries.
git-svn-id: trunk@58747 -
This commit is contained in:
parent
ff36f03b93
commit
5e3a683299
@ -25,9 +25,9 @@ object frmMain: TfrmMain
|
||||
Height = 487
|
||||
Top = 0
|
||||
Width = 400
|
||||
ActivePage = TabSheet2
|
||||
ActivePage = TabSheet1
|
||||
Align = alClient
|
||||
TabIndex = 1
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
object TabSheet1: TTabSheet
|
||||
Caption = 'Preparation'
|
||||
|
@ -378,6 +378,7 @@ procedure TfrmMain.FitCompleteHandler(Sender:TObject);
|
||||
const
|
||||
{$IF FPC_FullVersion >= 30004}
|
||||
MASK = '%-4s %10s %10s %10s %10s';
|
||||
CONF_MASK = '%-4s %10s %10s %10s';
|
||||
{$ELSE}
|
||||
MASK = '%-4s %10s %10s %10s';
|
||||
{$IFEND}
|
||||
@ -389,6 +390,7 @@ var
|
||||
L: Integer;
|
||||
decsep: Char;
|
||||
paramName: String;
|
||||
confL, confH: Double;
|
||||
begin
|
||||
decsep := DefaultFormatSettings.DecimalSeparator;
|
||||
with lbResults.Items do begin
|
||||
@ -421,6 +423,24 @@ begin
|
||||
]));
|
||||
end;
|
||||
Add('');
|
||||
{$IF FPC_FullVersion >= 30004}
|
||||
Add('CONFIDENCE LIMITS');
|
||||
Add(Format(CONF_MASK, ['Name', 'Value', 'Lower', 'Upper']));
|
||||
for i := 0 to FitSeries.ParamCount - 1 do begin
|
||||
case FitSeries.FitEquation of
|
||||
fePolynomial: paramname := Format('b[%d]', [i]);
|
||||
else paramname := PARAM_NAME[i];
|
||||
end;
|
||||
FitSeries.GetConfidenceLimits(i, confL, confH);
|
||||
Add(Format(CONF_MASK, [
|
||||
paramName,
|
||||
MyFormatFloat(FitSeries.Param[i], STD_FMT, EXP_FMT),
|
||||
MyFormatFloat(confL, STD_FMT, EXP_FMT),
|
||||
MyFormatFloat(confH, STD_FMT, EXP_FMT)
|
||||
]));
|
||||
end;
|
||||
Add('');
|
||||
{$IFEND}
|
||||
Add('ANALYSIS OF VARIANCE');
|
||||
lbResults.Canvas.Font.Assign(lbResults.Font);
|
||||
FReportDecimals := 5;
|
||||
|
@ -335,6 +335,9 @@ type
|
||||
procedure ExecFit; virtual;
|
||||
function EquationText: IFitEquationText;
|
||||
function FitParams: TDoubleDynArray;
|
||||
{$IF FPC_FullVersion >= 30004}
|
||||
procedure GetConfidenceLimits(AIndex: Integer; out ALower, AUpper: Double);
|
||||
{$IFEND}
|
||||
function GetFitEquationString(
|
||||
ANumFormat: String; AXText: String = 'x'; AYText: String = 'y'): String;
|
||||
deprecated 'Use EquationText';
|
||||
@ -1721,6 +1724,25 @@ begin
|
||||
Result[i] := Param[i];
|
||||
end;
|
||||
|
||||
{$IF FPC_FullVersion >= 30004}
|
||||
procedure TFitSeries.GetConfidenceLimits(AIndex: Integer; out ALower, AUpper: Double);
|
||||
var
|
||||
val, sig, t: Double;
|
||||
alpha: Double;
|
||||
begin
|
||||
val := GetParam_RawValue(AIndex);
|
||||
sig := GetParam_RawError(AIndex);
|
||||
alpha := 1.0 - FConfidenceLevel;
|
||||
t := invtdist(alpha, Statistics.DOF, 2);
|
||||
ALower := val - sig*t;
|
||||
AUpper := val + sig*t;
|
||||
if (FFitEquation in [feExp, fePower]) and (AIndex = 0) then begin
|
||||
ALower := exp(ALower);
|
||||
AUpper := exp(AUpper);
|
||||
end;
|
||||
end;
|
||||
{$IFEND}
|
||||
|
||||
function TFitSeries.GetFitEquationString(ANumFormat: String; AXText: String;
|
||||
AYText: String): String;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user