2020-04-26 22:36:07 +00:00
|
|
|
// Testing: no file needed
|
|
|
|
//
|
|
|
|
// Test input parameters:
|
|
|
|
// - F distribution: DF1 = 3, DF2 = 20
|
|
|
|
|
2020-08-24 22:36:30 +00:00
|
|
|
// ToDo: Fix calculation of t distribution
|
|
|
|
|
2020-03-30 18:01:44 +00:00
|
|
|
unit DistribUnit;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2020-08-24 22:36:30 +00:00
|
|
|
Classes, SysUtils, FileUtil, TAGraph, TAFuncSeries, TASeries, TATools,
|
|
|
|
PrintersDlgs, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|
|
|
Printers, ExtCtrls, ExtDlgs, Math, FunctionsLib, Globals;
|
2020-03-30 18:01:44 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TDistribFrm }
|
|
|
|
|
|
|
|
TDistribFrm = class(TForm)
|
|
|
|
AlphaEdit: TEdit;
|
2020-04-26 22:36:07 +00:00
|
|
|
Bevel1: TBevel;
|
2020-08-24 22:36:30 +00:00
|
|
|
ChartToolset: TChartToolset;
|
|
|
|
PanDragTool: TPanDragTool;
|
|
|
|
tChk: TRadioButton;
|
|
|
|
ZoomDragTool: TZoomDragTool;
|
|
|
|
PrintDialog: TPrintDialog;
|
|
|
|
SavePictureDialog: TSavePictureDialog;
|
|
|
|
VertLineSeries: TLineSeries;
|
|
|
|
FuncSeries: TFuncSeries;
|
2020-08-24 22:54:29 +00:00
|
|
|
ParameterPanel: TPanel;
|
2020-08-24 22:36:30 +00:00
|
|
|
SaveBtn: TButton;
|
|
|
|
PrintBtn: TButton;
|
|
|
|
Chart: TChart;
|
2020-04-26 22:36:07 +00:00
|
|
|
ChiChk: TRadioButton;
|
2020-03-30 18:01:44 +00:00
|
|
|
DF1Edit: TEdit;
|
|
|
|
DF2Edit: TEdit;
|
2020-04-26 22:36:07 +00:00
|
|
|
FChk: TRadioButton;
|
2020-03-30 18:01:44 +00:00
|
|
|
MeanEdit: TEdit;
|
2020-04-26 22:36:07 +00:00
|
|
|
NDChk: TRadioButton;
|
2020-08-24 22:54:29 +00:00
|
|
|
ChartPanel: TPanel;
|
2020-03-30 18:01:44 +00:00
|
|
|
ResetBtn: TButton;
|
|
|
|
ComputeBtn: TButton;
|
2020-04-26 22:36:07 +00:00
|
|
|
CloseBtn: TButton;
|
2020-03-30 18:01:44 +00:00
|
|
|
GroupBox2: TGroupBox;
|
|
|
|
AlphaLabel: TLabel;
|
2020-04-26 22:36:07 +00:00
|
|
|
DF1Label: TLabel;
|
|
|
|
DF2Label: TLabel;
|
|
|
|
MeanLabel: TLabel;
|
2020-03-30 18:01:44 +00:00
|
|
|
GroupBox1: TGroupBox;
|
|
|
|
procedure ComputeBtnClick(Sender: TObject);
|
2020-04-26 22:36:07 +00:00
|
|
|
procedure FormActivate(Sender: TObject);
|
2020-03-30 18:01:44 +00:00
|
|
|
procedure FormShow(Sender: TObject);
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure CalcChiSq(const AX: Double; out AY: Double);
|
|
|
|
procedure CalcF(const AX: Double; out AY: Double);
|
|
|
|
procedure CalcND(const AX: Double; out AY: Double);
|
|
|
|
procedure Calct(const AX: Double; out AY: Double);
|
2020-08-26 21:20:02 +00:00
|
|
|
procedure DistributionClick(Sender: TObject);
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure PrintBtnClick(Sender: TObject);
|
2020-03-30 18:01:44 +00:00
|
|
|
procedure ResetBtnClick(Sender: TObject);
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure SaveBtnClick(Sender: TObject);
|
2020-03-30 18:01:44 +00:00
|
|
|
private
|
|
|
|
{ private declarations }
|
2020-08-24 22:36:30 +00:00
|
|
|
DF1: Integer;
|
|
|
|
DF2: Integer;
|
2020-08-26 21:20:02 +00:00
|
|
|
procedure NormalDistPlot;
|
2020-04-26 22:36:07 +00:00
|
|
|
procedure ChiPlot;
|
|
|
|
procedure FPlot;
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure tPlot;
|
2020-04-26 22:36:07 +00:00
|
|
|
|
|
|
|
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
|
2020-03-30 18:01:44 +00:00
|
|
|
public
|
|
|
|
{ public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
DistribFrm: TDistribFrm;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2020-08-24 22:36:30 +00:00
|
|
|
uses
|
2020-08-26 21:20:02 +00:00
|
|
|
TAChartUtils, TADrawerSVG, TAPrint,
|
|
|
|
MathUnit;
|
2020-08-24 22:36:30 +00:00
|
|
|
|
|
|
|
|
2020-03-30 18:01:44 +00:00
|
|
|
{ TDistribFrm }
|
|
|
|
|
|
|
|
procedure TDistribFrm.ResetBtnClick(Sender: TObject);
|
|
|
|
begin
|
2020-04-26 22:36:07 +00:00
|
|
|
NDChk.Checked := false;
|
2020-08-24 22:36:30 +00:00
|
|
|
tChk.Checked := false;
|
2020-04-26 22:36:07 +00:00
|
|
|
FChk.Checked := false;
|
2020-08-24 22:36:30 +00:00
|
|
|
ChiChk.Checked := false;
|
2020-04-26 22:36:07 +00:00
|
|
|
AlphaEdit.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL);
|
|
|
|
DF1Edit.Text := '';
|
|
|
|
DF2Edit.Text := '';
|
|
|
|
MeanEdit.Text := '';
|
|
|
|
GroupBox2.Enabled := false;
|
2020-08-24 22:36:30 +00:00
|
|
|
FuncSeries.OnCalculate := nil;
|
|
|
|
VertLineSeries.Active := false;
|
|
|
|
Chart.Title.Visible := false;
|
|
|
|
Chart.BottomAxis.Title.Caption := 'Scale';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDistribFrm.SaveBtnClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
ext: String;
|
|
|
|
begin
|
|
|
|
if SavePictureDialog.Execute then
|
|
|
|
begin
|
|
|
|
ext := Lowercase(ExtractFileExt(SavePictureDialog.FileName));
|
|
|
|
case ext of
|
|
|
|
'.bmp': Chart.SaveToFile(TBitmap, SavePictureDialog.Filename);
|
|
|
|
'.png': Chart.SaveToFile(TPortableNetworkGraphic, SavePictureDialog.FileName);
|
|
|
|
'.jpg', '.jpeg', '.jpe', '.jfif': Chart.SaveToFile(TJpegImage, SavePictureDialog.FileName);
|
|
|
|
'.svg': Chart.SaveToSVGFile(SavePictureDialog.FileName);
|
|
|
|
end;
|
|
|
|
end;
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDistribFrm.FormShow(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ResetBtnClick(self);
|
|
|
|
end;
|
|
|
|
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure TDistribFrm.CalcF(const AX: Double; out AY: Double);
|
|
|
|
begin
|
2020-08-26 21:20:02 +00:00
|
|
|
AY := FDensity(AX, DF1, DF2);
|
2020-08-24 22:36:30 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDistribFrm.CalcND(const AX: Double; out AY: Double);
|
|
|
|
begin
|
|
|
|
AY := 1.0 / sqrt(TWO_PI) * exp(-sqr(AX)/ 2.0);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDistribFrm.CalcChiSq(const AX: Double; out AY: Double);
|
|
|
|
begin
|
2020-08-26 21:20:02 +00:00
|
|
|
AY := Chi2Density(AX, DF1);
|
2020-08-24 22:36:30 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDistribFrm.Calct(const AX: Double; out AY: Double);
|
|
|
|
begin
|
2020-08-26 21:20:02 +00:00
|
|
|
AY := tDensity(AX, DF1);
|
2020-08-24 22:36:30 +00:00
|
|
|
end;
|
|
|
|
|
2020-08-26 21:20:02 +00:00
|
|
|
procedure TDistribFrm.DistributionClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
rb: TRadiobutton;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2020-08-26 21:20:02 +00:00
|
|
|
rb := Sender as TRadioButton;
|
|
|
|
|
|
|
|
GroupBox2.Enabled := rb.Checked;
|
|
|
|
|
|
|
|
AlphaLabel.Enabled := rb.Checked;
|
|
|
|
AlphaEdit.Enabled := rb.Checked;
|
|
|
|
|
|
|
|
DF1Edit.Enabled := (rb <> NDChk) and rb.Checked;
|
|
|
|
DF1Label.Enabled := DF1Edit.Enabled;
|
|
|
|
|
|
|
|
DF2Edit.Enabled := (rb = FChk) and rb.Checked;
|
|
|
|
DF2Label.Enabled := DF2Edit.Enabled;
|
|
|
|
|
|
|
|
MeanEdit.Enabled := false;
|
|
|
|
MeanLabel.Enabled := false;
|
|
|
|
{
|
|
|
|
|
2020-03-30 18:01:44 +00:00
|
|
|
if NDChk.Checked then
|
|
|
|
begin
|
|
|
|
GroupBox2.Enabled := true;
|
|
|
|
AlphaLabel.Enabled := true;
|
|
|
|
AlphaEdit.Enabled := true;
|
|
|
|
DF1Edit.Enabled := false;
|
2020-04-26 22:36:07 +00:00
|
|
|
DF1Label.Enabled := false;
|
|
|
|
DF2Label.Enabled := false;
|
|
|
|
MeanLabel.Enabled := false;
|
2020-03-30 18:01:44 +00:00
|
|
|
DF2Edit.Enabled := false;
|
|
|
|
MeanEdit.Enabled := false;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
GroupBox2.Enabled := false;
|
2020-08-26 21:20:02 +00:00
|
|
|
}
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure TDistribFrm.PrintBtnClick(Sender: TObject);
|
|
|
|
const
|
|
|
|
MARGIN = 10;
|
|
|
|
var
|
|
|
|
R: TRect;
|
|
|
|
d: Integer;
|
|
|
|
begin
|
|
|
|
if not PrintDialog.Execute then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
Printer.BeginDoc;
|
|
|
|
try
|
|
|
|
R := Rect(0, 0, Printer.PageWidth, Printer.PageHeight div 2);
|
|
|
|
|
|
|
|
d := R.Right - R.Left;
|
|
|
|
R.Left += d div MARGIN;
|
|
|
|
R.Right -= d div MARGIN;
|
|
|
|
|
|
|
|
d := R.Bottom - R.Top;
|
|
|
|
R.Top += d div MARGIN;
|
|
|
|
R.Bottom -= d div MARGIN;
|
|
|
|
|
|
|
|
Chart.Draw(TPrinterDrawer.Create(Printer, true), R);
|
|
|
|
finally
|
|
|
|
Printer.EndDoc;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-03-30 18:01:44 +00:00
|
|
|
procedure TDistribFrm.ComputeBtnClick(Sender: TObject);
|
2020-04-26 22:36:07 +00:00
|
|
|
var
|
|
|
|
msg: String;
|
|
|
|
C: TWinControl;
|
|
|
|
ok: Boolean;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2020-04-26 22:36:07 +00:00
|
|
|
if not Validate(msg, C) then
|
|
|
|
begin
|
|
|
|
C.SetFocus;
|
|
|
|
MessageDlg(msg, mtError, [mbOK], 0);
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
ok := false;
|
|
|
|
if NDChk.Checked then
|
|
|
|
begin
|
2020-08-26 21:20:02 +00:00
|
|
|
NormalDistPlot();
|
2020-04-26 22:36:07 +00:00
|
|
|
ok := true;
|
|
|
|
end;
|
|
|
|
|
2020-08-24 22:36:30 +00:00
|
|
|
if tChk.Checked then
|
|
|
|
begin
|
|
|
|
tPlot();
|
|
|
|
ok := true;
|
|
|
|
end;
|
|
|
|
|
2020-04-26 22:36:07 +00:00
|
|
|
if ChiChk.Checked then
|
|
|
|
begin
|
|
|
|
ChiPlot();
|
|
|
|
ok := true;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if FChk.Checked then
|
|
|
|
begin
|
|
|
|
FPlot();
|
|
|
|
ok := true;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if not ok then
|
|
|
|
MessageDlg('Please select a distribution.', mtError, [mbOK], 0);
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
2020-08-26 21:20:02 +00:00
|
|
|
procedure TDistribFrm.NormalDistPlot;
|
2020-03-30 18:01:44 +00:00
|
|
|
var
|
2020-08-24 22:36:30 +00:00
|
|
|
alpha: Double;
|
2020-08-24 22:54:29 +00:00
|
|
|
zMax, zCrit, pCrit: Double;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2020-04-26 22:36:07 +00:00
|
|
|
alpha := StrToFloat(AlphaEdit.Text);
|
2020-08-24 22:54:29 +00:00
|
|
|
zMax := InverseZ(0.9999);
|
2020-08-24 22:36:30 +00:00
|
|
|
zCrit := inversez(1.0 - alpha);
|
|
|
|
CalcND(zCrit, pCrit);
|
|
|
|
|
|
|
|
Chart.Title.Text.Clear;
|
|
|
|
Chart.Title.Text.Add('<b>Normal Distribution</b>');
|
|
|
|
Chart.Title.Text.Add(Format('α = %.3g', [alpha]));
|
|
|
|
Chart.Title.Text.Add(Format('Critical value = %.3f', [zCrit]));
|
|
|
|
Chart.Title.Visible := true;
|
|
|
|
Chart.BottomAxis.Title.Caption := 'z';
|
2020-08-24 22:54:29 +00:00
|
|
|
FuncSeries.Extent.XMin := -zMax;
|
|
|
|
FuncSeries.Extent.XMax := +zMax;
|
2020-08-24 22:36:30 +00:00
|
|
|
FuncSeries.Extent.UseXMin := true;
|
|
|
|
FuncSeries.Extent.UseXMax := true;
|
|
|
|
FuncSeries.OnCalculate := @CalcND;
|
|
|
|
FuncSeries.DomainExclusions.Clear;
|
|
|
|
VertLineSeries.Clear;
|
|
|
|
VertLineSeries.AddXY(zCrit, 0);
|
|
|
|
VertLineSeries.AddXY(zCrit, pCrit);
|
|
|
|
VertLineSeries.Active := true;
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
2020-04-26 22:36:07 +00:00
|
|
|
procedure TDistribFrm.ChiPlot;
|
2020-03-30 18:01:44 +00:00
|
|
|
var
|
2020-08-24 22:36:30 +00:00
|
|
|
alpha: Double;
|
2020-08-24 22:54:29 +00:00
|
|
|
Chi2Max, Chi2Crit, pCrit: Double;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2020-04-26 22:36:07 +00:00
|
|
|
alpha := StrToFloat(AlphaEdit.Text);
|
2020-08-24 22:36:30 +00:00
|
|
|
DF1 := StrToInt(DF1Edit.Text);
|
2020-08-24 22:54:29 +00:00
|
|
|
Chi2Max := InverseChi(0.9999, DF1);
|
2020-08-24 22:36:30 +00:00
|
|
|
Chi2Crit := InverseChi(1.0 - alpha, DF1);
|
|
|
|
CalcChiSq(Chi2Crit, pCrit);
|
|
|
|
|
|
|
|
Chart.Title.Text.Clear;
|
2020-08-24 22:54:29 +00:00
|
|
|
Chart.Title.Text.Add('<b>Chi-Squared Distribution</b>');
|
2020-08-24 22:36:30 +00:00
|
|
|
Chart.Title.Text.Add(Format('α = %.3g / Degrees of freedom = %d', [alpha, DF1]));
|
|
|
|
Chart.Title.Text.Add(Format('Critical value = %.3f', [Chi2Crit]));
|
|
|
|
Chart.Title.Visible := true;
|
|
|
|
Chart.BottomAxis.Title.Caption := 'χ<sup>2</sup>';
|
|
|
|
FuncSeries.Extent.XMin := 0;
|
2020-08-24 22:54:29 +00:00
|
|
|
FuncSeries.Extent.XMax := Chi2Max;
|
2020-08-24 22:36:30 +00:00
|
|
|
FuncSeries.Extent.UseXMin := true;
|
|
|
|
FuncSeries.Extent.UseXMax := true;
|
|
|
|
FuncSeries.OnCalculate := @CalcChiSq;
|
|
|
|
FuncSeries.DomainExclusions.AddRange(-Infinity, 0, [ioOpenEnd]);
|
|
|
|
VertLineSeries.Clear;
|
|
|
|
VertLineSeries.AddXY(Chi2Crit, 0);
|
|
|
|
VertLineSeries.AddXY(Chi2Crit, pCrit);
|
|
|
|
VertLineSeries.Active := true;
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
2020-04-26 22:36:07 +00:00
|
|
|
procedure TDistribFrm.FPlot;
|
2020-03-30 18:01:44 +00:00
|
|
|
var
|
2020-08-24 22:36:30 +00:00
|
|
|
alpha: Double;
|
2020-08-24 22:54:29 +00:00
|
|
|
FMax, FCrit, pCrit: Double;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2020-04-26 22:36:07 +00:00
|
|
|
alpha := StrToFloat(AlphaEdit.Text);
|
2020-08-24 22:36:30 +00:00
|
|
|
DF1 := StrToInt(DF1Edit.Text);
|
|
|
|
DF2 := StrToInt(DF2Edit.Text);
|
2020-08-24 22:54:29 +00:00
|
|
|
FMax := FPercentPoint(0.999, DF1, DF2);
|
2020-08-24 22:36:30 +00:00
|
|
|
FCrit := FPercentPoint(1.0 - alpha, DF1, DF2);
|
|
|
|
CalcF(FCrit, pCrit);
|
|
|
|
|
|
|
|
Chart.Title.Text.Clear;
|
2020-08-24 22:54:29 +00:00
|
|
|
Chart.Title.Text.Add('<b>F Distribution</b>');
|
2020-08-24 22:36:30 +00:00
|
|
|
Chart.Title.Text.Add(Format('α = %.3g / DF1 = %d, DF2 = %d', [alpha, DF1, DF2]));
|
|
|
|
Chart.Title.Text.Add(Format('Critical value = %.3f', [FCrit]));
|
|
|
|
Chart.Title.Visible := true;
|
|
|
|
Chart.BottomAxis.Title.Caption := 'F';
|
|
|
|
FuncSeries.Extent.XMin := 0;
|
2020-08-24 22:54:29 +00:00
|
|
|
FuncSeries.Extent.XMax := FMax;
|
2020-08-24 22:36:30 +00:00
|
|
|
FuncSeries.Extent.UseXMin := true;
|
|
|
|
FuncSeries.Extent.UseXMax := true;
|
|
|
|
FuncSeries.OnCalculate := @CalcF;
|
|
|
|
FuncSeries.DomainExclusions.AddRange(-Infinity, 0, [ioOpenEnd]);
|
|
|
|
VertLineSeries.Clear;
|
|
|
|
VertLineSeries.AddXY(FCrit, 0);
|
|
|
|
VertLineSeries.AddXY(FCrit, pCrit);
|
|
|
|
VertLineSeries.Active := true;
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
2020-08-24 22:36:30 +00:00
|
|
|
procedure TDistribFrm.tPlot;
|
2020-03-30 18:01:44 +00:00
|
|
|
var
|
2020-08-24 22:36:30 +00:00
|
|
|
alpha: Double;
|
2020-08-24 22:54:29 +00:00
|
|
|
tMax, tCrit, pCrit: Double;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2020-08-24 22:36:30 +00:00
|
|
|
alpha := StrToFloat(AlphaEdit.Text);
|
|
|
|
DF1 := StrToInt(DF1Edit.Text);
|
2020-08-24 22:54:29 +00:00
|
|
|
tMax := Inverset(0.9999, DF1);
|
2020-08-24 22:36:30 +00:00
|
|
|
tCrit := Inverset(1.0 - alpha, DF1);
|
|
|
|
Calct(tCrit, pCrit);
|
|
|
|
|
|
|
|
Chart.Title.Text.Clear;
|
2020-08-24 22:54:29 +00:00
|
|
|
Chart.Title.Text.Add('<b>Student t Distribution</b>');
|
2020-08-24 22:36:30 +00:00
|
|
|
Chart.Title.Text.Add(Format('α = %.3g / Degrees of freedom = %d', [alpha, DF1]));
|
|
|
|
Chart.Title.Text.Add(Format('Critical value = %.3f', [tCrit]));
|
|
|
|
Chart.Title.Visible := true;
|
|
|
|
Chart.BottomAxis.Title.Caption := 't';
|
2020-08-26 21:20:02 +00:00
|
|
|
FuncSeries.Extent.XMin := -tmax;
|
2020-08-24 22:54:29 +00:00
|
|
|
FuncSeries.Extent.XMax := tMax;
|
2020-08-24 22:36:30 +00:00
|
|
|
FuncSeries.Extent.UseXMin := true;
|
|
|
|
FuncSeries.Extent.UseXMax := true;
|
|
|
|
FuncSeries.OnCalculate := @Calct;
|
|
|
|
FuncSeries.DomainExclusions.Clear;
|
|
|
|
VertLineSeries.Clear;
|
|
|
|
VertLineSeries.AddXY(tCrit, 0);
|
|
|
|
VertLineSeries.AddXY(tCrit, pCrit);
|
|
|
|
VertLineSeries.Active := true;
|
2020-04-26 22:36:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDistribFrm.FormActivate(Sender: TObject);
|
|
|
|
var
|
|
|
|
w: Integer;
|
|
|
|
begin
|
2020-08-24 22:36:30 +00:00
|
|
|
w := MaxValue([SaveBtn.Width, PrintBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
|
2020-08-24 22:54:29 +00:00
|
|
|
SaveBtn.Constraints.MinWidth := w;
|
|
|
|
PrintBtn.Constraints.MinWidth := w;
|
2020-04-26 22:36:07 +00:00
|
|
|
ResetBtn.Constraints.MinWidth := w;
|
|
|
|
ComputeBtn.Constraints.MinWidth := w;
|
|
|
|
CloseBtn.Constraints.MinWidth := w;
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2020-04-26 22:36:07 +00:00
|
|
|
function TDistribFrm.Validate(out AMsg: String; out AControl: TWinControl): boolean;
|
|
|
|
var
|
|
|
|
x: Double;
|
|
|
|
n: Integer;
|
|
|
|
begin
|
|
|
|
Result := false;
|
|
|
|
if AlphaEdit.Text = '' then
|
|
|
|
begin
|
|
|
|
AMsg := 'Input required.';
|
|
|
|
AControl := AlphaEdit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
if not TryStrToFloat(AlphaEdit.Text, x) or (x <= 0) or (x >= 1.0) then
|
|
|
|
begin
|
|
|
|
AMsg := 'Numerical value between 0 and 1 required.';
|
|
|
|
AControl := AlphaEdit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if ChiChk.Checked or FChk.Checked then
|
|
|
|
begin
|
|
|
|
if DF1Edit.Text = '' then
|
|
|
|
begin
|
|
|
|
AMsg := 'Input required.';
|
|
|
|
AControl := DF1Edit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
if not TryStrToInt(DF1Edit.Text, n) or (n <= 0) then
|
|
|
|
begin
|
|
|
|
AMsg := 'Positive numerical value required.';
|
|
|
|
AControl := DF1Edit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if FChk.Checked then
|
|
|
|
begin
|
|
|
|
if DF2Edit.Text = '' then
|
|
|
|
begin
|
|
|
|
AMsg := 'Input required.';
|
|
|
|
AControl := DF2Edit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
if not TryStrToInt(DF2Edit.Text, n) or (n <= 0) then
|
|
|
|
begin
|
|
|
|
AMsg := 'Positive numerical value required.';
|
|
|
|
AControl := DF2Edit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
(*
|
|
|
|
if MeanEdit.Text = '' then
|
|
|
|
begin
|
|
|
|
AMsg := 'Input required.';
|
|
|
|
AControl := MeanEdit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
if not TryStrToFloat(MeanEdit.Text, x) then
|
|
|
|
begin
|
|
|
|
AMsg := 'Numerical value required.';
|
|
|
|
AControl := MeanEdit;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
*)
|
|
|
|
|
|
|
|
Result := true;
|
|
|
|
end;
|
|
|
|
|
2020-03-30 18:01:44 +00:00
|
|
|
initialization
|
|
|
|
{$I distribunit.lrs}
|
|
|
|
|
|
|
|
end.
|
|
|
|
|