Lazstats: Finetuning and chm help file update of the CompareDistUnit, StemLeafUnit and ResistanceUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8028 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-05-12 13:45:32 +00:00
parent 3965b4a1ec
commit a9c9aa1c73
8 changed files with 53 additions and 40 deletions

Binary file not shown.

View File

@ -25,25 +25,28 @@ inherited CompareDistFrm: TCompareDistFrm
end end
inherited HelpBtn: TButton inherited HelpBtn: TButton
Top = 494 Top = 494
HelpType = htKeyword
HelpKeyword = 'html/ComparisonsWithTheoreticalDistri.htm'
TabOrder = 7 TabOrder = 7
Visible = False
end end
inherited ButtonBevel: TBevel inherited ButtonBevel: TBevel
Top = 478 Top = 478
end end
object OptionsGroup: TGroupBox[5] object OptionsGroup: TGroupBox[5]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonBevel AnchorSideBottom.Control = ButtonBevel
Left = 0 Left = 0
Height = 110 Height = 110
Top = 368 Top = 368
Width = 294 Width = 291
Anchors = [akLeft, akBottom] Anchors = [akLeft, akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Top = 8 BorderSpacing.Top = 8
Caption = 'Options' Caption = 'Options'
ClientHeight = 90 ClientHeight = 90
ClientWidth = 290 ClientWidth = 287
TabOrder = 6 TabOrder = 6
object BothChk: TCheckBox object BothChk: TCheckBox
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = OptionsGroup

View File

@ -113,7 +113,7 @@ implementation
uses uses
Math, Math,
TACustomSeries, TASeries, TACustomSeries, TASeries,
Utils, MathUnit; Utils, GridProcs, MathUnit;
{ TCompareDistFrm } { TCompareDistFrm }
@ -140,7 +140,7 @@ procedure TCompareDistFrm.AdjustConstraints;
begin begin
Notebook.AutoSize := true; Notebook.AutoSize := true;
ParamsPanel.Constraints.MinWidth := Max( ParamsPanel.Constraints.MinWidth := Max(
3*CloseBtn.Width + 2*CloseBtn.BorderSpacing.Left, 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
Min( Min(
CompareGroup.Width * 2 - Var1InBtn.Width + VarList.BorderSpacing.Right, CompareGroup.Width * 2 - Var1InBtn.Width + VarList.BorderSpacing.Right,
OptionsGroup.Width) OptionsGroup.Width)
@ -165,7 +165,7 @@ begin
// count values in these intervals // count values in these intervals
for j := 1 to NoCases do for j := 1 to NoCases do
begin begin
if not ValidValue(j, AColIndex) then continue; if not DataProcs.ValidValue(j, AColIndex) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[AColIndex, j]); value := StrToFloat(OS3MainFrm.DataGrid.Cells[AColIndex, j]);
for k := 0 to ANumIntervals-1 do for k := 0 to ANumIntervals-1 do
begin begin
@ -249,7 +249,7 @@ begin
numCases := 0; numCases := 0;
for j := 1 to NoCases do for j := 1 to NoCases do
begin begin
if not ValidValue(j, AColIndex) then continue; if not DataProcs.ValidValue(j, AColIndex) then continue;
value := StrToFloat(OS3MainFrm.DataGrid.Cells[AColIndex, j]); value := StrToFloat(OS3MainFrm.DataGrid.Cells[AColIndex, j]);
if value > AMax then AMax := value; if value > AMax then AMax := value;
if value < AMin then AMin := value; if value < AMin then AMin := value;
@ -328,25 +328,19 @@ var
C: TWinControl; C: TWinControl;
begin begin
// Get columns of the variables // Get columns of the variables
col1 := 0; col1 := GetVariableIndex(OS3MainFrm.DataGrid, VarOneEdit.Text);
for i := 1 to NoVariables do col2 := GetVariableIndex(OS3MainFrm.DataGrid, VarTwoEdit.Text);
if VarOneEdit.Text = OS3MainFrm.DataGrid.Cells[i, 0] then col1 := i;
col2 := 0;
if CompareTo = ctVariable then
for i := 1 to NoVariables do
if VarTwoEdit.Text = OS3MainFrm.DataGrid.Cells[i, 0] then col2 := i;
// Check existence of required variables // Check existence of required variables
msg := ''; msg := '';
case CompareTo of case CompareTo of
ctTheoreticalDistrib: ctTheoreticalDistrib:
if col1 = 0 then if col1 = -1 then
msg := 'Variable not specified.'; msg := 'Variable not specified.';
ctVariable: ctVariable:
if col1 = 0 then if col1 = -1 then
msg := 'Variable One is not specified.' msg := 'Variable One is not specified.'
else if col2 = 0 then else if col2 = -1 then
msg := 'Variable Two is not specified.'; msg := 'Variable Two is not specified.';
end; end;
if msg <> '' then if msg <> '' then
@ -583,7 +577,7 @@ procedure TCompareDistFrm.UpdateDF1;
AMean := 0; AMean := 0;
ANumCases := 0; ANumCases := 0;
for i := 1 to NoCases do for i := 1 to NoCases do
if ValidValue(i, col) then if DataProcs.ValidValue(i, col) then
begin begin
AMean := AMean + StrToFloat(OS3MainFrm.DataGrid.Cells[col, i]); AMean := AMean + StrToFloat(OS3MainFrm.DataGrid.Cells[col, i]);
inc(ANumCases); inc(ANumCases);

View File

@ -8,6 +8,7 @@ inherited ResistanceLineForm: TResistanceLineForm
Caption = 'Resistant Line for Bivariate Data' Caption = 'Resistant Line for Bivariate Data'
ClientHeight = 438 ClientHeight = 438
ClientWidth = 883 ClientWidth = 883
OnCreate = FormCreate
inherited ParamsPanel: TPanel inherited ParamsPanel: TPanel
Height = 422 Height = 422
Width = 320 Width = 320
@ -333,13 +334,13 @@ inherited ResistanceLineForm: TResistanceLineForm
Left = 0 Left = 0
Height = 228 Height = 228
Top = 153 Top = 153
Width = 264 Width = 276
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Options' Caption = 'Options'
ClientHeight = 208 ClientHeight = 208
ClientWidth = 260 ClientWidth = 272
TabOrder = 7 TabOrder = 7
object ConfLabel: TLabel object ConfLabel: TLabel
AnchorSideLeft.Control = OptionsGroup AnchorSideLeft.Control = OptionsGroup
@ -427,6 +428,7 @@ inherited ResistanceLineForm: TResistanceLineForm
Top = 177 Top = 177
Width = 248 Width = 248
BorderSpacing.Left = 12 BorderSpacing.Left = 12
BorderSpacing.Right = 12
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
Caption = 'Enter Predicted Y and Residual Y in the Grid' Caption = 'Enter Predicted Y and Residual Y in the Grid'
TabOrder = 6 TabOrder = 6
@ -467,7 +469,7 @@ inherited ResistanceLineForm: TResistanceLineForm
Left = 12 Left = 12
Height = 12 Height = 12
Top = 46 Top = 46
Width = 236 Width = 248
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12 BorderSpacing.Left = 12
BorderSpacing.Right = 12 BorderSpacing.Right = 12

View File

@ -42,6 +42,7 @@ type
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
Label4: TLabel; Label4: TLabel;
procedure FormCreate(Sender: TObject);
procedure PlotMediansChkChange(Sender: TObject); procedure PlotMediansChkChange(Sender: TObject);
procedure StdCorChkChange(Sender: TObject); procedure StdCorChkChange(Sender: TObject);
procedure VarListDblClick(Sender: TObject); procedure VarListDblClick(Sender: TObject);
@ -212,6 +213,12 @@ begin
end; end;
procedure TResistanceLineForm.FormCreate(Sender: TObject);
begin
ConfEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
end;
procedure TResistanceLineForm.PlotMedians(const XMedians, YMedians: DblDyneVec; procedure TResistanceLineForm.PlotMedians(const XMedians, YMedians: DblDyneVec;
Aslope, AIntercept: Double); Aslope, AIntercept: Double);
var var
@ -380,8 +387,6 @@ end;
procedure TResistanceLineForm.Reset; procedure TResistanceLineForm.Reset;
var
i: integer;
begin begin
inherited; inherited;
@ -391,10 +396,7 @@ begin
XEdit.Text := ''; XEdit.Text := '';
YEdit.Text := ''; YEdit.Text := '';
VarList.Clear; CollectVariableNames(OS3MainFrm.DataGrid, VarList.Items);
ConfEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates; UpdateBtnStates;
end; end;

View File

@ -25,6 +25,8 @@ inherited StemLeafForm: TStemLeafForm
inherited HelpBtn: TButton inherited HelpBtn: TButton
Tag = 148 Tag = 148
Top = 298 Top = 298
HelpType = htKeyword
HelpKeyword = 'html/StemandLeafPlot.htm'
TabOrder = 6 TabOrder = 6
end end
inherited ButtonBevel: TBevel inherited ButtonBevel: TBevel

View File

@ -1,3 +1,7 @@
{ NOTE: The calculation in this unit is probably in error because the result of
the sample file is different from the one shown in Bill's book with the same
data file. }
unit StemLeafUnit; unit StemLeafUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
@ -33,6 +37,7 @@ type
procedure AdjustConstraints; override; procedure AdjustConstraints; override;
procedure Compute; override; procedure Compute; override;
procedure UpdateBtnStates; override; procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): boolean; override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@ -100,11 +105,6 @@ var
begin begin
noselected := SelectList.Items.Count; noselected := SelectList.Items.Count;
if (noselected = 0) then
begin
ErrorMsg('No variables were selected.');
exit;
end;
SetLength(selected, noselected); SetLength(selected, noselected);
SetLength(bins, 100); SetLength(bins, 100);
@ -352,14 +352,9 @@ begin
end; end;
procedure TStemLeafForm.Reset; procedure TStemLeafForm.Reset;
var
i: integer;
begin begin
inherited; inherited;
CollectVariableNames(OS3MainFrm.DataGrid, VarList.Items);
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
SelectList.Clear; SelectList.Clear;
UpdateBtnStates; UpdateBtnStates;
end; end;
@ -406,6 +401,21 @@ begin
end; end;
function TStemLeafForm.Validate(out AMsg: String; out AControl: TWinControl): boolean;
begin
Result := false;
if SelectList.Items.Count = 0 then
begin
AMsg := 'No variables were selected.';
AControl := VarList;
exit;
end;
Result := true;
end;
procedure TStemLeafForm.VarListDblClick(Sender: TObject); procedure TStemLeafForm.VarListDblClick(Sender: TObject);
var var
index: Integer; index: Integer;