2020-03-30 18:01:44 +00:00
|
|
|
unit InverseZUnit;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2021-06-04 09:59:27 +00:00
|
|
|
StdCtrls, ExtCtrls;
|
2020-03-30 18:01:44 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TInversezForm }
|
|
|
|
|
|
|
|
TInversezForm = class(TForm)
|
|
|
|
Bevel1: TBevel;
|
|
|
|
CancelBtn: TButton;
|
|
|
|
ComputeBtn: TButton;
|
|
|
|
Panel1: TPanel;
|
|
|
|
ResetBtn: TButton;
|
|
|
|
ReturnBtn: TButton;
|
|
|
|
ZEdit: TEdit;
|
|
|
|
Label2: TLabel;
|
|
|
|
ProbEdit: TEdit;
|
|
|
|
Label1: TLabel;
|
|
|
|
procedure ComputeBtnClick(Sender: TObject);
|
|
|
|
procedure FormActivate(Sender: TObject);
|
|
|
|
procedure ResetBtnClick(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ private declarations }
|
|
|
|
public
|
|
|
|
{ public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
InversezForm: TInversezForm;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2021-06-04 09:59:27 +00:00
|
|
|
{$R *.lfm}
|
|
|
|
|
2020-03-30 18:01:44 +00:00
|
|
|
uses
|
2021-06-04 09:59:27 +00:00
|
|
|
Math, MathUnit, Utils;
|
2020-03-30 18:01:44 +00:00
|
|
|
|
|
|
|
{ TInversezForm }
|
|
|
|
|
|
|
|
procedure TInversezForm.ResetBtnClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ProbEdit.Text := '';
|
|
|
|
ZEdit.Text := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TInversezForm.ComputeBtnClick(Sender: TObject);
|
2021-06-04 09:59:27 +00:00
|
|
|
var
|
|
|
|
prob, zScore: double;
|
2020-03-30 18:01:44 +00:00
|
|
|
begin
|
2021-06-04 09:59:27 +00:00
|
|
|
if not MyTryStrToFloat(ProbEdit.Text, prob) then
|
|
|
|
begin
|
|
|
|
ProbEdit.SetFocus;
|
|
|
|
ErrorMsg('No valid number.');
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
zScore := InverseNormalDist(prob);
|
|
|
|
ZEdit.Text := Format('%6.4f', [zScore]);
|
2020-03-30 18:01:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TInversezForm.FormActivate(Sender: TObject);
|
|
|
|
var
|
|
|
|
w: Integer;
|
|
|
|
begin
|
|
|
|
w := MaxValue([CancelBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
|
|
|
|
CancelBtn.Constraints.MinWidth := w;
|
|
|
|
ResetBtn.Constraints.MinWidth := w;
|
|
|
|
ComputeBtn.Constraints.MinWidth := w;
|
|
|
|
ReturnBtn.Constraints.MinWidth := w;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|