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

View File

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

View File

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

View File

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

View File

@ -25,6 +25,8 @@ inherited StemLeafForm: TStemLeafForm
inherited HelpBtn: TButton
Tag = 148
Top = 298
HelpType = htKeyword
HelpKeyword = 'html/StemandLeafPlot.htm'
TabOrder = 6
end
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;
{$mode objfpc}{$H+}
@ -33,6 +37,7 @@ type
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): boolean; override;
public
constructor Create(AOwner: TComponent); override;
@ -100,11 +105,6 @@ var
begin
noselected := SelectList.Items.Count;
if (noselected = 0) then
begin
ErrorMsg('No variables were selected.');
exit;
end;
SetLength(selected, noselected);
SetLength(bins, 100);
@ -352,14 +352,9 @@ begin
end;
procedure TStemLeafForm.Reset;
var
i: integer;
begin
inherited;
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
CollectVariableNames(OS3MainFrm.DataGrid, VarList.Items);
SelectList.Clear;
UpdateBtnStates;
end;
@ -406,6 +401,21 @@ begin
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);
var
index: Integer;