LazStats: Inherit SimpleChiSqrUnit from TBasicStatsReportForm. Some refactoring.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7840 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-11-03 15:09:13 +00:00
parent d660825c51
commit 4613e36150
3 changed files with 219 additions and 464 deletions

View File

@@ -68,4 +68,5 @@ correlation, means, standard deviations and confidence interval for each correla
164=This procedure smooths data by averaging every three data points starting with the first three to the last three. The data smoothing can be repeated multiple times. The first and last data points are unchanged. 164=This procedure smooths data by averaging every three data points starting with the first three to the last three. The data smoothing can be repeated multiple times. The first and last data points are unchanged.
165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button. 165=This is a test for the randomness of a series of values in a variable. Select the variable to analyze and click the Compute button.
166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis. 166=Sens method for the detection and estimation of trents is used to analyze one or more variable observations collected at equally spaced intervals of time.\nFirst, select one or more series variables to analyze.\nNext, if you have entered more than one variable, indicate how the measures are to be combined (mean or median) and if the values are to be standardized (z scores with mean of 0 and standard deviation of 1.)\nFinally, select the options desired and click the compute button to complete the analysis.
167=Notes: This is a non-parametric analysis of ordinal data.\nIt is similar to a two-way Analysis of Variance but utilizes a chi-square statistic (H) for determining the significance of the row, column and interaction effects. The dependent value, if not initially rank data, may be obtained first by creating a new variable with the "transformation" procedure available under the "Variables" menu. The output of this procedure contains the results both of a "traditional" 2-way ANOVA as well as the SRH results.\nIt should be noted that the power of the SRH analysis is less than that of the traditional ANOVA. It is suggested that there be at least 5 or more cases in each cell and that the design is a balanced design of fixed levels.\nThe H statistic is obtained as the division of the sum of squares for an effect by the mean square of the total and the test is performed by a chi-squared probability with the degrees of freedom equal to the SS of the effect being tested. 167=Notes: This is a non-parametric analysis of ordinal data.\nIt is similar to a two-way Analysis of Variance but utilizes a chi-square statistic (H) for determining the significance of the row, column and interaction effects. The dependent value, if not initially rank data, may be obtained first by creating a new variable with the "transformation" procedure available under the "Variables" menu. The output of this procedure contains the results both of a "traditional" 2-way ANOVA as well as the SRH results.\nIt should be noted that the power of the SRH analysis is less than that of the traditional ANOVA. It is suggested that there be at least 5 or more cases in each cell and that the design is a balanced design of fixed levels.\nThe H statistic is obtained as the division of the sum of squares for an effect by the mean square of the total and the test is performed by a chi-squared probability with the degrees of freedom equal to the SS of the effect being tested.
168=This procedure lets you enter the number of observed values and the number of expected values for one or more categories.\nEnter the values as indicated and when finished, press the compute button.

View File

@@ -1,357 +1,123 @@
object SimpleChiSqrForm: TSimpleChiSqrForm inherited SimpleChiSqrForm: TSimpleChiSqrForm
Left = 827 Left = 827
Height = 436 Height = 266
Top = 221 Top = 221
Width = 408 Width = 703
Caption = 'Simple ChiSquare for Categories' Caption = 'Simple ChiSquare for Categories'
ClientHeight = 436 ClientHeight = 266
ClientWidth = 408 ClientWidth = 703
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 250
OnResize = FormResize ClientHeight = 250
OnShow = ResetBtnClick inherited CloseBtn: TButton
Position = poMainFormCenter Top = 225
LCLVersion = '2.1.0.0' TabOrder = 5
object Label1: TLabel
AnchorSideTop.Control = NcatsEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NcatsEdit
Left = 168
Height = 30
Top = 65
Width = 166
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Enter the number of categories:'#13#10'Click the mouse after entering.'
ParentColor = False
end
object NcatsEdit: TEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Memo1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 342
Height = 23
Top = 69
Width = 58
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 16
BorderSpacing.Right = 8
BorderSpacing.Bottom = 16
OnClick = NcatsEditExit
OnExit = NcatsEditExit
TabOrder = 0
Text = '1'
end
object ComputeBtn: TButton
AnchorSideRight.Control = ReturnBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 251
Height = 25
Top = 403
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 185
Height = 25
Top = 403
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 4
end
object ReturnBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 339
Height = 25
Top = 403
Width = 61
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Return'
ModalResult = 1
TabOrder = 6
end
object Label5: TLabel
AnchorSideTop.Control = TotChiSqrEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = TotChiSqrEdit
Left = 152
Height = 15
Top = 341
Width = 96
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Total ChiSquare = '
ParentColor = False
end
object TotChiSqrEdit: TEdit
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ProbEdit
Left = 256
Height = 23
Top = 337
Width = 144
Alignment = taRightJustify
Anchors = [akRight, akBottom]
BorderSpacing.Top = 12
BorderSpacing.Bottom = 4
ReadOnly = True
TabOrder = 2
end
object Label6: TLabel
AnchorSideTop.Control = ProbEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ProbEdit
Left = 172
Height = 15
Top = 368
Width = 76
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Probability >='
ParentColor = False
end
object ProbEdit: TEdit
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 256
Height = 23
Top = 364
Width = 144
Alignment = taRightJustify
Anchors = [akRight, akBottom]
BorderSpacing.Top = 3
ReadOnly = True
TabOrder = 3
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReturnBtn
Left = 0
Height = 8
Top = 387
Width = 408
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Memo1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 45
Top = 8
Width = 392
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 8
Caption = 'This procedure lets you enter the number of observed values and the number of expected values for one or more categories. Enter the values as indicated and when finished, press the compute button.'
ParentColor = False
WordWrap = True
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = NcatsEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = TotChiSqrEdit
Left = 8
Height = 217
Top = 108
Width = 392
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 24
ChildSizing.EnlargeHorizontal = crsScaleChilds
ChildSizing.EnlargeVertical = crsScaleChilds
ChildSizing.ShrinkHorizontal = crsHomogenousChildResize
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 217
ClientWidth = 392
TabOrder = 1
object Panel2: TPanel
Left = 0
Height = 217
Top = 0
Width = 115
BevelOuter = bvNone
ClientHeight = 217
ClientWidth = 115
TabOrder = 0
object Label2: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel2
Left = 18
Height = 15
Top = 0
Width = 79
BorderSpacing.Left = 8
Caption = 'Freq. Observed'
Constraints.MinHeight = 15
ParentColor = False
end
object ObservedGrid: TStringGrid
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 200
Top = 17
Width = 115
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True
BorderSpacing.Top = 2
ColCount = 1
Constraints.MinHeight = 200
FixedCols = 0
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 0
ColWidths = (
111
)
end
end end
object Panel3: TPanel inherited ComputeBtn: TButton
Left = 139 Top = 225
Height = 217 TabOrder = 4
Top = 0
Width = 115
BevelOuter = bvNone
ClientHeight = 217
ClientWidth = 115
TabOrder = 1
object Label3: TLabel
AnchorSideLeft.Control = Panel3
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel3
Left = 17
Height = 15
Top = 0
Width = 80
Caption = 'Freq. Expected:'
Constraints.MaxHeight = 15
ParentColor = False
end
object ExpectedGrid: TStringGrid
AnchorSideLeft.Control = Panel3
AnchorSideTop.Control = Label3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel3
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel3
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 200
Top = 17
Width = 115
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True
BorderSpacing.Top = 2
ColCount = 1
FixedCols = 0
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 0
ColWidths = (
111
)
end
end end
object Panel4: TPanel inherited ResetBtn: TButton
AnchorSideBottom.Side = asrBottom Top = 225
Left = 278 TabOrder = 3
Height = 217 end
Top = 0 inherited HelpBtn: TButton
Width = 114 Tag = 168
BevelOuter = bvNone Top = 225
ClientHeight = 217
ClientWidth = 114
TabOrder = 2 TabOrder = 2
object Label4: TLabel
AnchorSideLeft.Control = Panel4
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel4
AnchorSideRight.Side = asrBottom
Left = 11
Height = 15
Top = 0
Width = 93
BorderSpacing.Right = 8
Caption = 'Computed Values'
ParentColor = False
end
object ChiSqrGrid: TStringGrid
AnchorSideLeft.Control = Panel4
AnchorSideTop.Control = Label4
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel4
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel4
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 200
Top = 17
Width = 114
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True
BorderSpacing.Top = 2
ColCount = 1
FixedCols = 0
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 0
ColWidths = (
110
)
end
end end
inherited ButtonBevel: TBevel
Top = 209
end
object Label1: TLabel[5]
AnchorSideTop.Side = asrCenter
Left = 59
Height = 30
Top = 0
Width = 166
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Enter the number of categories:'#13#10'Click the mouse after entering.'
ParentColor = False
end
object ObsLabel: TLabel[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom
Left = 0
Height = 15
Top = 56
Width = 63
Caption = 'Frequencies'
Constraints.MinHeight = 15
ParentColor = False
end
object Bevel1: TBevel[7]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
Left = 137
Height = 68
Top = 104
Width = 16
Shape = bsSpacer
end
object DataGrid: TStringGrid[8]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ObsLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonBevel
Left = 0
Height = 136
Top = 73
Width = 291
Anchors = [akTop, akLeft, akRight, akBottom]
AutoAdvance = aaDown
AutoFillColumns = True
BorderSpacing.Top = 2
ColCount = 3
DefaultColWidth = 30
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goThumbTracking, goSmoothScroll, goFixedRowNumbering]
TabOrder = 1
OnPrepareCanvas = DataGridPrepareCanvas
ColWidths = (
30
128
129
)
Cells = (
2
1
0
'Observed'
2
0
'Expected'
)
end
object NcatsEdit: TSpinEdit[9]
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
Left = 233
Height = 23
Top = 4
Width = 58
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Bottom = 16
MaxValue = 65535
MinValue = 1
OnEditingDone = NcatsEditEditingDone
TabOrder = 0
Value = 1
end
end
inherited ParamsSplitter: TSplitter
Height = 266
end end
end end

View File

@@ -5,157 +5,145 @@ unit SimpleChiSqrUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, SpinEx, Forms, Controls, Graphics, Dialogs,
StdCtrls, Grids, ExtCtrls, StdCtrls, Grids, ExtCtrls, Spin,
MainUnit, Globals, FunctionsLib, OutputUnit; Globals, FunctionsLib, BasicStatsReportFormUnit;
type type
{ TSimpleChiSqrForm } { TSimpleChiSqrForm }
TSimpleChiSqrForm = class(TForm) TSimpleChiSqrForm = class(TBasicStatsReportForm)
Bevel1: TBevel; Bevel1: TBevel;
ComputeBtn: TButton; NcatsEdit: TSpinEdit;
Memo1: TLabel; ObsLabel: TLabel;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
ProbEdit: TEdit;
Label6: TLabel;
TotChiSqrEdit: TEdit;
Label5: TLabel;
ResetBtn: TButton;
ReturnBtn: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
NcatsEdit: TEdit;
Label1: TLabel; Label1: TLabel;
ObservedGrid: TStringGrid; DataGrid: TStringGrid;
ExpectedGrid: TStringGrid; procedure DataGridPrepareCanvas(Sender: TObject; {%H-}ACol, ARow: Integer;
ChiSqrGrid: TStringGrid; {%H-}AState: TGridDrawState);
procedure ComputeBtnClick(Sender: TObject); procedure NcatsEditEditingDone(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure NcatsEditExit(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private private
{ private declarations }
FAutoSized: Boolean; protected
NoCats: integer; procedure AdjustConstraints; override;
procedure Compute; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override;
end; end;
var var
SimpleChiSqrForm: TSimpleChiSqrForm; SimpleChiSqrForm: TSimpleChiSqrForm;
implementation implementation
uses {$R *.lfm}
Math;
{ TSimpleChiSqrForm } { TSimpleChiSqrForm }
procedure TSimpleChiSqrForm.NcatsEditExit(Sender: TObject); constructor TSimpleChiSqrForm.Create(AOwner: TComponent);
begin begin
NoCats := StrToInt(NcatsEdit.Text); inherited;
ObservedGrid.RowCount := NoCats+1; NCatsEdit.Value := 1;
ExpectedGrid.RowCount := NoCats+1;
ChiSqrGrid.RowCount := NoCats+1;
end; end;
procedure TSimpleChiSqrForm.ComputeBtnClick(Sender: TObject);
procedure TSimpleChiSqrForm.AdjustConstraints;
begin
inherited;
ParamsPanel.Constraints.MinWidth := 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left;
ParamsPanel.Constraints.MinHeight := 300;
end;
procedure TSimpleChiSqrForm.Compute;
var var
TotalChiSqr : double; totalChiSqr, chiSqr, ObsValue, ExpValue, chiProb: double;
ChiSqr, Obs, Exp, ChiProb, NObs, NExp : double; i, nObs, nExp: integer;
i : integer; lReport: TStrings;
outline : string; noCats: Integer;
begin begin
OutputFrm.RichEdit.Clear; noCats := DataGrid.RowCount - DataGrid.FixedRows;
OutputFrm.RichEdit.Lines.Add('Simple Chi-Square Analysis Results');
OutputFrm.RichEdit.Lines.Add('Category ChiSquare'); lReport := TStringList.Create;
TotalChiSqr := 0.0; try
NObs := 0.0; lReport.Add('SIMPLE CHI-SQUARE ANALYSIS RESULTS');
NExp := 0.0; lReport.Add('');
for i := 1 to NoCats do lReport.Add('Number of categories: ' + IntToStr(noCats));
begin lReport.Add('');
Obs := StrToFloat(ObservedGrid.Cells[0,i]); lReport.Add('Category Observed Expected ChiSquare ');
NObs := NObs + 1; lReport.Add('-------- ---------- ---------- ----------');
Exp := StrToFloat(ExpectedGrid.Cells[0,i]);
NExp := NExp + 1; TotalChiSqr := 0.0;
chisqr := sqr(Obs - Exp) / Exp; nObs := 0;
outline := format('%8.3f',[chisqr]); nExp := 0;
ChiSqrGrid.Cells[0,i] := outline; for i := 1 to NoCats do
TotalChiSqr := TotalChiSqr + chisqr; begin
outline := format(' %2d %8.3f',[i,chisqr]); ObsValue := StrToFloat(DataGrid.Cells[1, i]);
OutputFrm.RichEdit.Lines.Add(outline); nObs := nObs + 1;
end; ExpValue := StrToFloat(DataGrid.Cells[2, i]);
OutputFrm.RichEdit.Lines.Add(''); if ExpValue <> 0 then
TotChiSqrEdit.Text := FloatToStr(TotalChiSqr); begin
ChiProb := 1.0 - ChiSquaredProb(TotalChiSqr,NoCats); nExp := nExp + 1;
ProbEdit.Text := FloatToStr(ChiProb); chisqr := sqr(ObsValue - ExpValue) / ExpValue;
outline := format('Number Observed = %8.3f',[NObs]); totalChiSqr := totalChiSqr + chisqr;
OutputFrm.RichEdit.Lines.Add(outline); lReport.Add('%8d %10.3f %10.3f %10.3f', [i, obsValue, expValue, chiSqr]);
outline := format('Number Expected = %8.3f',[NExp]); end else
OutputFrm.RichEdit.Lines.Add(outline); lReport.Add('%8d %10.3f %10.3f %-10s', [i, obsValue, expvalue, 'ERROR: Division by 0']);
outline := format('ChiSquare = %8.3f with Probability of a larger value = %8.3f', end;
[TotalChiSqr,ChiProb]); lReport.Add('');
OutputFrm.RichEdit.Lines.Add(outline);
OutputFrm.ShowModal; chiProb := 1.0 - ChiSquaredProb(totalChiSqr, nExp);
OutputFrm.RichEdit.Clear;
lReport.Add('Number observed: %8d', [nObs]);
lReport.Add('Number expected: %8d', [nExp]);
lReport.Add('Total Chi-Square: %8.3f', [totalChiSqr]);
lReport.Add(' with probability of a larger value %8.3f', [chiProb]);
FReportFrame.Displayreport(lReport);
finally
lReport.Free;
end;
end; end;
procedure TSimpleChiSqrForm.FormActivate(Sender: TObject);
procedure TSimpleChiSqrForm.DataGridPrepareCanvas(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState);
var var
w: Integer; grid: TStringGrid;
ts: TTextStyle;
begin begin
if FAutoSized then grid := (Sender as TStringGrid);
exit; ts := grid.Canvas.TextStyle;
if ARow > 0 then
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]); ts.Alignment := taRightJustify
ResetBtn.Constraints.MinWidth := w; else
ComputeBtn.Constraints.MinWidth := w; ts.Alignment := taCenter;
ReturnBtn.Constraints.MinWidth := w; grid.Canvas.TextStyle := ts;
FAutoSized := true;
end; end;
procedure TSimpleChiSqrForm.FormCreate(Sender: TObject);
procedure TSimpleChiSqrForm.NcatsEditEditingDone(Sender: TObject);
begin begin
Assert(OS3MainFrm <> nil); DataGrid.RowCount := NCatsEdit.Value + DataGrid.FixedRows;
if OutputFrm = nil then
Application.CreateForm(TOutputFrm, OutputFrm);
end; end;
procedure TSimpleChiSqrForm.FormResize(Sender: TObject);
var procedure TSimpleChiSqrForm.Reset;
w: Integer;
dist: Integer;
begin begin
dist := ObservedGrid.BorderSpacing.Left + ChiSqrGrid.BorderSpacing.Right; inherited;
w := Width div 3 - dist;
ObservedGrid.Width := w; DataGrid.RowCount := NCatsEdit.Value + DataGrid.FixedRows;
ExpectedGrid.Width := w; DataGrid.Cols[1].Clear;
ChiSqrGrid.Width := w; DataGrid.Cols[2].Clear;
DataGrid.Cells[1, 0] := 'Observed';
DataGrid.Cells[2, 0] := 'Expected';
end; end;
procedure TSimpleChiSqrForm.ResetBtnClick(Sender: TObject);
begin
NoCats := 1;
ObservedGrid.RowCount := NoCats + 1;
ExpectedGrid.RowCount := NoCats + 1;
ChiSqrGrid.RowCount := NoCats + 1;
NCatsEdit.Text := '1';
ObservedGrid.Cells[0,0] := 'Observed';
ExpectedGrid.Cells[0,0] := 'Expected';
ChiSqrGrid.Cells[0,0] := 'ChiSquared';
end;
initialization
{$I simplechisqrunit.lrs}
end. end.