You've already forked lazarus-ccr
LazStats: Accept both decimal separators in the sub-menu forms of "Simulations" > "Probabilities"
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8048 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -29,7 +29,7 @@ object FForm: TFForm
|
|||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -45,7 +45,7 @@ object FForm: TFForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -61,7 +61,7 @@ object FForm: TFForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -79,7 +79,7 @@ object FForm: TFForm
|
|||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -108,18 +108,18 @@ object FForm: TFForm
|
|||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 85
|
ClientHeight = 85
|
||||||
ClientWidth = 412
|
ClientWidth = 412
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideTop.Control = FEdit
|
AnchorSideTop.Control = FEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = Label4
|
AnchorSideRight.Control = Label4
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 88
|
Left = 102
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 117
|
Width = 103
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Given: An F statistic = '
|
Caption = 'Given: An F statistic'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object FEdit: TEdit
|
object FEdit: TEdit
|
||||||
@ -141,12 +141,12 @@ object FForm: TFForm
|
|||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = Label4
|
AnchorSideRight.Control = Label4
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 88
|
Left = 91
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 117
|
Width = 114
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'with Deg. Freedom of '
|
Caption = 'with deg. freedom of '
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object DF1Edit: TEdit
|
object DF1Edit: TEdit
|
||||||
@ -199,7 +199,7 @@ object FForm: TFForm
|
|||||||
Height = 15
|
Height = 15
|
||||||
Top = 66
|
Top = 66
|
||||||
Width = 205
|
Width = 205
|
||||||
Caption = 'then the probability of a larger value = '
|
Caption = 'then the probability of a larger value is'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbEdit: TEdit
|
object ProbEdit: TEdit
|
||||||
|
@ -41,8 +41,10 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, MathUnit;
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TFForm }
|
{ TFForm }
|
||||||
|
|
||||||
@ -55,14 +57,33 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFForm.ComputeBtnClick(Sender: TObject);
|
procedure TFForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
F, df1, df2, prob : extended;
|
F, prob: Double;
|
||||||
|
df1, df2: Integer;
|
||||||
begin
|
begin
|
||||||
F := StrToFloat(FEdit.Text);
|
if not MyTryStrToFloat(FEdit.Text, F) then
|
||||||
df1 := StrToFloat(DF1Edit.Text);
|
begin
|
||||||
df2 := StrToFloat(DF2Edit.Text);
|
FEdit.SetFocus;
|
||||||
prob := ProbF(F,df1,df2);
|
ErrorMsg('No valid number.');
|
||||||
ProbEdit.Text := Format('%6.4f',[prob]);
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not TryStrToInt(DF1Edit.Text, df1) then
|
||||||
|
begin
|
||||||
|
DF1Edit.SetFocus;
|
||||||
|
ErrorMsg('No valid integer (must be positive).');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not TryStrToInt(DF2Edit.Text, df2) then
|
||||||
|
begin
|
||||||
|
DF2Edit.SetFocus;
|
||||||
|
ErrorMsg('No valid integer (must be positive).');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
prob := ProbF(F, df1, df2);
|
||||||
|
ProbEdit.Text := Format('%6.4f', [prob]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFForm.FormActivate(Sender: TObject);
|
procedure TFForm.FormActivate(Sender: TObject);
|
||||||
@ -77,8 +98,5 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
|
||||||
{$I fprobunit.lrs}
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ object InversezForm: TInversezForm
|
|||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -45,7 +45,7 @@ object InversezForm: TInversezForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -61,7 +61,7 @@ object InversezForm: TInversezForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -78,7 +78,7 @@ object InversezForm: TInversezForm
|
|||||||
BorderSpacing.Right = 16
|
BorderSpacing.Right = 16
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -97,29 +97,29 @@ object InversezForm: TInversezForm
|
|||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
Left = 54
|
Left = 65
|
||||||
Height = 54
|
Height = 54
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 239
|
Width = 217
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 54
|
ClientHeight = 54
|
||||||
ClientWidth = 239
|
ClientWidth = 217
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideTop.Control = ProbEdit
|
AnchorSideTop.Control = ProbEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = Label2
|
AnchorSideRight.Control = Label2
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 8
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 135
|
Width = 121
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Cumulative Probability = '
|
Caption = 'Cumulative Probability'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbEdit: TEdit
|
object ProbEdit: TEdit
|
||||||
@ -127,7 +127,7 @@ object InversezForm: TInversezForm
|
|||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = Panel1
|
||||||
AnchorSideRight.Control = ZEdit
|
AnchorSideRight.Control = ZEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 151
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 88
|
Width = 88
|
||||||
@ -143,8 +143,8 @@ object InversezForm: TInversezForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 35
|
Top = 35
|
||||||
Width = 143
|
Width = 121
|
||||||
Caption = 'Corresponds to a z value = '
|
Caption = 'Corresponding z value '
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ZEdit: TEdit
|
object ZEdit: TEdit
|
||||||
@ -152,7 +152,7 @@ object InversezForm: TInversezForm
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = ProbEdit
|
AnchorSideTop.Control = ProbEdit
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 151
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 88
|
Width = 88
|
||||||
|
@ -6,8 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, ExtCtrls,
|
StdCtrls, ExtCtrls;
|
||||||
Functionslib;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -38,8 +37,10 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math;
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TInversezForm }
|
{ TInversezForm }
|
||||||
|
|
||||||
@ -50,14 +51,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TInversezForm.ComputeBtnClick(Sender: TObject);
|
procedure TInversezForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
Prob, Zscore : double;
|
prob, zScore: double;
|
||||||
outvalue : string;
|
|
||||||
begin
|
begin
|
||||||
Prob := StrToFloat(ProbEdit.Text);
|
if not MyTryStrToFloat(ProbEdit.Text, prob) then
|
||||||
Zscore := inversez(Prob);
|
begin
|
||||||
outvalue := format('%6.4f',[Zscore]);
|
ProbEdit.SetFocus;
|
||||||
ZEdit.Text := outvalue;
|
ErrorMsg('No valid number.');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
zScore := InverseNormalDist(prob);
|
||||||
|
ZEdit.Text := Format('%6.4f', [zScore]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TInversezForm.FormActivate(Sender: TObject);
|
procedure TInversezForm.FormActivate(Sender: TObject);
|
||||||
@ -71,8 +75,5 @@ begin
|
|||||||
ReturnBtn.Constraints.MinWidth := w;
|
ReturnBtn.Constraints.MinWidth := w;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
|
||||||
{$I inversezunit.lrs}
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = ReturnBtn
|
AnchorSideTop.Control = ReturnBtn
|
||||||
@ -40,7 +40,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = ReturnBtn
|
AnchorSideTop.Control = ReturnBtn
|
||||||
@ -54,7 +54,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -73,7 +73,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -92,18 +92,18 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
Left = 86
|
Left = 93
|
||||||
Height = 85
|
Height = 85
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 217
|
Width = 203
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 85
|
ClientHeight = 85
|
||||||
ClientWidth = 217
|
ClientWidth = 203
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideTop.Control = ChiSqrEdit
|
AnchorSideTop.Control = ChiSqrEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
@ -112,10 +112,10 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
Left = 30
|
Left = 30
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 105
|
Width = 91
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
Caption = 'Chisquared value = '
|
Caption = 'Chisquared value'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ChiSqrEdit: TEdit
|
object ChiSqrEdit: TEdit
|
||||||
@ -123,7 +123,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = Panel1
|
||||||
AnchorSideRight.Control = ProbEdit
|
AnchorSideRight.Control = ProbEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 143
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 74
|
Width = 74
|
||||||
@ -140,10 +140,10 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
Left = 24
|
Left = 24
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 111
|
Width = 97
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
Caption = 'with deg. freedom = '
|
Caption = 'with deg. freedom'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object DFEdit: TEdit
|
object DFEdit: TEdit
|
||||||
@ -152,7 +152,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ProbEdit
|
AnchorSideRight.Control = ProbEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 143
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 27
|
Top = 27
|
||||||
Width = 74
|
Width = 74
|
||||||
@ -169,8 +169,8 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 66
|
Top = 66
|
||||||
Width = 135
|
Width = 121
|
||||||
Caption = 'Probability larger value = '
|
Caption = 'Probability larger value'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbEdit: TEdit
|
object ProbEdit: TEdit
|
||||||
@ -178,7 +178,7 @@ object ChiSqrProbForm: TChiSqrProbForm
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = DFEdit
|
AnchorSideTop.Control = DFEdit
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 143
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 62
|
Top = 62
|
||||||
Width = 74
|
Width = 74
|
||||||
|
@ -40,8 +40,10 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math;
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TChiSqrProbForm }
|
{ TChiSqrProbForm }
|
||||||
|
|
||||||
@ -53,16 +55,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChiSqrProbForm.ComputeBtnClick(Sender: TObject);
|
procedure TChiSqrProbForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
ChiSqr, Prob : double;
|
chiSqr, prob: double;
|
||||||
DF : integer;
|
DF: integer;
|
||||||
outvalue : string;
|
|
||||||
begin
|
begin
|
||||||
ChiSqr := StrToFloat(ChiSqrEdit.Text);
|
if not MyTryStrToFloat(ChiSqrEdit.Text, chiSqr) then
|
||||||
DF := StrToInt(DFEdit.Text);
|
begin
|
||||||
Prob := 1.0 - chisquaredprob(ChiSqr,DF);
|
ChiSqrEdit.SetFocus;
|
||||||
outvalue := format('%6.4f',[Prob]);
|
ErrorMsg('No valid number.');
|
||||||
ProbEdit.Text := outvalue;
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not TryStrToInt(DFEdit.Text, DF) or (DF <= 0) then begin
|
||||||
|
DFEdit.SetFocus;
|
||||||
|
ErrorMsg('No a valid integer (must be positive).');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
prob := 1.0 - ChiSquaredProb(ChiSqr, DF);
|
||||||
|
ProbEdit.Text := Format('%6.4f', [prob]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChiSqrProbForm.FormActivate(Sender: TObject);
|
procedure TChiSqrProbForm.FormActivate(Sender: TObject);
|
||||||
@ -76,8 +87,5 @@ begin
|
|||||||
ReturnBtn.Constraints.MinWidth := w;
|
ReturnBtn.Constraints.MinWidth := w;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
|
||||||
{$I probchisqrunit.lrs}
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ object ProbSmallerzForm: TProbSmallerzForm
|
|||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -45,7 +45,7 @@ object ProbSmallerzForm: TProbSmallerzForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -61,7 +61,7 @@ object ProbSmallerzForm: TProbSmallerzForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -79,38 +79,38 @@ object ProbSmallerzForm: TProbSmallerzForm
|
|||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
Left = 57
|
Left = 64
|
||||||
Height = 54
|
Height = 54
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 194
|
Width = 180
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 54
|
ClientHeight = 54
|
||||||
ClientWidth = 194
|
ClientWidth = 180
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideTop.Control = zEdit
|
AnchorSideTop.Control = zEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 103
|
Width = 89
|
||||||
Caption = 'Observed z score = '
|
Caption = 'Observed z score'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object zEdit: TEdit
|
object zEdit: TEdit
|
||||||
AnchorSideLeft.Control = Label1
|
AnchorSideLeft.Control = Label1
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = Panel1
|
||||||
Left = 111
|
Left = 97
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 83
|
Width = 83
|
||||||
@ -127,9 +127,9 @@ object ProbSmallerzForm: TProbSmallerzForm
|
|||||||
Left = 13
|
Left = 13
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 35
|
Top = 35
|
||||||
Width = 90
|
Width = 76
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Probability < z = '
|
Caption = 'Probability < z'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbzEdit: TEdit
|
object ProbzEdit: TEdit
|
||||||
@ -138,7 +138,7 @@ object ProbSmallerzForm: TProbSmallerzForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = zEdit
|
AnchorSideRight.Control = zEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 111
|
Left = 97
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 83
|
Width = 83
|
||||||
|
@ -6,8 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, ExtCtrls,
|
StdCtrls, ExtCtrls;
|
||||||
Functionslib;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -38,26 +37,31 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math;
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TProbSmallerzForm }
|
{ TProbSmallerzForm }
|
||||||
|
|
||||||
procedure TProbSmallerzForm.ResetBtnClick(Sender: TObject);
|
procedure TProbSmallerzForm.ResetBtnClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
zEdit.Text := '';
|
zEdit.Text := '';
|
||||||
ProbzEdit.Text := '';
|
ProbzEdit.Text := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProbSmallerzForm.ComputeBtnClick(Sender: TObject);
|
procedure TProbSmallerzForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
zprob, z : double;
|
zprob, z: double;
|
||||||
outvalue : string;
|
|
||||||
begin
|
begin
|
||||||
z := StrToFloat(zEdit.Text);
|
if not MyTryStrToFloat(zEdit.Text, z) then
|
||||||
zprob := probz(z);
|
begin
|
||||||
outvalue := format('%6.4f',[zprob]);
|
zEdit.SetFocus;
|
||||||
ProbzEdit.Text := outvalue;
|
ErrorMsg('No valid number.');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
zProb := NormalDist(z);
|
||||||
|
ProbzEdit.Text := Format('%6.4f', [zProb]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProbSmallerzForm.FormActivate(Sender: TObject);
|
procedure TProbSmallerzForm.FormActivate(Sender: TObject);
|
||||||
@ -71,8 +75,5 @@ begin
|
|||||||
ReturnBtn.Constraints.MinWidth := w;
|
ReturnBtn.Constraints.MinWidth := w;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
|
||||||
{$I probsmallerzunit.lrs}
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ object ProbzForm: TProbzForm
|
|||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -45,7 +45,7 @@ object ProbzForm: TProbzForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -61,7 +61,7 @@ object ProbzForm: TProbzForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -79,7 +79,7 @@ object ProbzForm: TProbzForm
|
|||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -98,18 +98,18 @@ object ProbzForm: TProbzForm
|
|||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
Left = 58
|
Left = 65
|
||||||
Height = 55
|
Height = 55
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 194
|
Width = 180
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 55
|
ClientHeight = 55
|
||||||
ClientWidth = 194
|
ClientWidth = 180
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideLeft.Control = Panel1
|
AnchorSideLeft.Control = Panel1
|
||||||
AnchorSideTop.Control = zEdit
|
AnchorSideTop.Control = zEdit
|
||||||
@ -117,14 +117,14 @@ object ProbzForm: TProbzForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 103
|
Width = 89
|
||||||
Caption = 'Observed z score = '
|
Caption = 'Observed z score'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object zEdit: TEdit
|
object zEdit: TEdit
|
||||||
AnchorSideLeft.Control = Label1
|
AnchorSideLeft.Control = Label1
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
Left = 111
|
Left = 97
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 83
|
Width = 83
|
||||||
@ -141,16 +141,16 @@ object ProbzForm: TProbzForm
|
|||||||
Left = 13
|
Left = 13
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 36
|
Top = 36
|
||||||
Width = 90
|
Width = 76
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Probability > z = '
|
Caption = 'Probability > z'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbzEdit: TEdit
|
object ProbzEdit: TEdit
|
||||||
AnchorSideLeft.Control = zEdit
|
AnchorSideLeft.Control = zEdit
|
||||||
AnchorSideRight.Control = zEdit
|
AnchorSideRight.Control = zEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 111
|
Left = 97
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 32
|
Top = 32
|
||||||
Width = 83
|
Width = 83
|
||||||
|
@ -6,8 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, ExtCtrls,
|
StdCtrls, ExtCtrls;
|
||||||
FunctionsLib;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -38,8 +37,10 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math;
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TProbzForm }
|
{ TProbzForm }
|
||||||
|
|
||||||
@ -50,14 +51,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProbzForm.ComputeBtnClick(Sender: TObject);
|
procedure TProbzForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
zprob, z : double;
|
zprob, z: double;
|
||||||
outvalue : string;
|
|
||||||
begin
|
begin
|
||||||
z := StrToFloat(zEdit.Text);
|
if not MyTryStrToFloat(zEdit.Text, z) then
|
||||||
zprob := 1.0 - probz(z);
|
begin
|
||||||
outvalue := format('%6.4f',[zprob]);
|
zEdit.SetFocus;
|
||||||
ProbzEdit.Text := outvalue;
|
ErrorMsg('No valid number.');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
zProb := 1.0 - NormalDist(z);
|
||||||
|
ProbzEdit.Text := Format('%6.4f', [zProb]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProbzForm.FormActivate(Sender: TObject);
|
procedure TProbzForm.FormActivate(Sender: TObject);
|
||||||
@ -71,8 +75,5 @@ begin
|
|||||||
ReturnBtn.Constraints.MinWidth := w;
|
ReturnBtn.Constraints.MinWidth := w;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
|
||||||
{$I probzunit.lrs}
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ object TProbForm: TTProbForm
|
|||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -45,7 +45,7 @@ object TProbForm: TTProbForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -61,7 +61,7 @@ object TProbForm: TTProbForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
@ -79,7 +79,7 @@ object TProbForm: TTProbForm
|
|||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -98,18 +98,18 @@ object TProbForm: TTProbForm
|
|||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
Left = 87
|
Left = 94
|
||||||
Height = 85
|
Height = 85
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 217
|
Width = 203
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 85
|
ClientHeight = 85
|
||||||
ClientWidth = 217
|
ClientWidth = 203
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideTop.Control = tValueEdit
|
AnchorSideTop.Control = tValueEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
@ -118,9 +118,9 @@ object TProbForm: TTProbForm
|
|||||||
Left = 42
|
Left = 42
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 93
|
Width = 79
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Student t value = '
|
Caption = 'Student t value'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object tValueEdit: TEdit
|
object tValueEdit: TEdit
|
||||||
@ -128,7 +128,7 @@ object TProbForm: TTProbForm
|
|||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = Panel1
|
||||||
AnchorSideRight.Control = ProbEdit
|
AnchorSideRight.Control = ProbEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 143
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 74
|
Width = 74
|
||||||
@ -145,9 +145,9 @@ object TProbForm: TTProbForm
|
|||||||
Left = 24
|
Left = 24
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 111
|
Width = 97
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'with deg. freedom = '
|
Caption = 'with deg. freedom'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object DFEdit: TEdit
|
object DFEdit: TEdit
|
||||||
@ -156,7 +156,7 @@ object TProbForm: TTProbForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ProbEdit
|
AnchorSideRight.Control = ProbEdit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 143
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 27
|
Top = 27
|
||||||
Width = 74
|
Width = 74
|
||||||
@ -173,8 +173,8 @@ object TProbForm: TTProbForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 66
|
Top = 66
|
||||||
Width = 135
|
Width = 121
|
||||||
Caption = 'Probability larger value = '
|
Caption = 'Probability larger value'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbEdit: TEdit
|
object ProbEdit: TEdit
|
||||||
@ -182,7 +182,7 @@ object TProbForm: TTProbForm
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = DFEdit
|
AnchorSideTop.Control = DFEdit
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 143
|
Left = 129
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 62
|
Top = 62
|
||||||
Width = 74
|
Width = 74
|
||||||
|
@ -42,7 +42,7 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, MathUnit;
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TTProbForm }
|
{ TTProbForm }
|
||||||
|
|
||||||
@ -54,18 +54,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTProbForm.ComputeBtnClick(Sender: TObject);
|
procedure TTProbForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
tvalue, dfvalue, prob : double;
|
tvalue, prob: double;
|
||||||
outvalue : string;
|
dfValue: Integer;
|
||||||
begin
|
begin
|
||||||
tvalue := StrToFloat(tValueEdit.Text);
|
if not MyTryStrToFloat(tValueEdit.Text, tvalue) then
|
||||||
dfvalue := StrToFloat(DFEdit.Text);
|
begin
|
||||||
if tvalue >= 0.0 then prob := 0.5 * ProbT(tvalue,dfvalue);
|
tValueEdit.SetFocus;
|
||||||
if tvalue < 0.0 then prob := 1.0 - ProbT(tvalue,dfvalue) +
|
ErrorMsg('No valid number.');
|
||||||
(0.5 * probt(tvalue,dfvalue)) ;
|
exit;
|
||||||
if tvalue = 0.0 then prob := 0.50;
|
end;
|
||||||
outvalue := format('%6.4f',[prob]);
|
|
||||||
ProbEdit.Text := outvalue;
|
if not TryStrToInt(DFEdit.Text, dfValue) then
|
||||||
|
begin
|
||||||
|
dfEdit.SetFocus;
|
||||||
|
ErrorMsg('Not a valid integer (must be positive).');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if tvalue >= 0.0 then
|
||||||
|
prob := 0.5 * ProbT(tvalue, dfvalue)
|
||||||
|
else if tvalue < 0.0 then
|
||||||
|
prob := 1.0 - ProbT(tvalue, dfvalue) + (0.5 *ProbT(tvalue, dfvalue))
|
||||||
|
else
|
||||||
|
prob := 0.50;
|
||||||
|
|
||||||
|
ProbEdit.Text := Format('%6.4f', [prob]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTProbForm.FormActivate(Sender: TObject);
|
procedure TTProbForm.FormActivate(Sender: TObject);
|
||||||
|
@ -8,6 +8,7 @@ object TwozProbForm: TTwozProbForm
|
|||||||
Caption = 'Probability between two z scores'
|
Caption = 'Probability between two z scores'
|
||||||
ClientHeight = 147
|
ClientHeight = 147
|
||||||
ClientWidth = 378
|
ClientWidth = 378
|
||||||
|
OnActivate = FormActivate
|
||||||
OnShow = ResetBtnClick
|
OnShow = ResetBtnClick
|
||||||
Position = poMainFormCenter
|
Position = poMainFormCenter
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
@ -15,25 +16,25 @@ object TwozProbForm: TTwozProbForm
|
|||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ResetBtn
|
AnchorSideRight.Control = ResetBtn
|
||||||
Left = 57
|
Left = 81
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 109
|
Top = 109
|
||||||
Width = 62
|
Width = 62
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 32
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Cancel = True
|
Cancel = True
|
||||||
Caption = 'Cancel'
|
Caption = 'Cancel'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 0
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ResetBtn: TButton
|
object ResetBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ComputeBtn
|
AnchorSideRight.Control = ComputeBtn
|
||||||
Left = 131
|
Left = 155
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 109
|
Top = 109
|
||||||
Width = 54
|
Width = 54
|
||||||
@ -43,13 +44,13 @@ object TwozProbForm: TTwozProbForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Reset'
|
Caption = 'Reset'
|
||||||
OnClick = ResetBtnClick
|
OnClick = ResetBtnClick
|
||||||
TabOrder = 1
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object ComputeBtn: TButton
|
object ComputeBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ReturnBtn
|
AnchorSideRight.Control = ReturnBtn
|
||||||
Left = 197
|
Left = 221
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 109
|
Top = 109
|
||||||
Width = 76
|
Width = 76
|
||||||
@ -59,25 +60,25 @@ object TwozProbForm: TTwozProbForm
|
|||||||
BorderSpacing.Right = 12
|
BorderSpacing.Right = 12
|
||||||
Caption = 'Compute'
|
Caption = 'Compute'
|
||||||
OnClick = ComputeBtnClick
|
OnClick = ComputeBtnClick
|
||||||
TabOrder = 2
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object ReturnBtn: TButton
|
object ReturnBtn: TButton
|
||||||
AnchorSideTop.Control = Bevel1
|
AnchorSideTop.Control = Bevel1
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 285
|
Left = 309
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 109
|
Top = 109
|
||||||
Width = 61
|
Width = 61
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 32
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Return'
|
Caption = 'Return'
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
TabOrder = 3
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
@ -96,18 +97,18 @@ object TwozProbForm: TTwozProbForm
|
|||||||
AnchorSideLeft.Control = Owner
|
AnchorSideLeft.Control = Owner
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
Left = 74
|
Left = 81
|
||||||
Height = 85
|
Height = 85
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 231
|
Width = 217
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 85
|
ClientHeight = 85
|
||||||
ClientWidth = 231
|
ClientWidth = 217
|
||||||
TabOrder = 4
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideLeft.Control = Panel1
|
AnchorSideLeft.Control = Panel1
|
||||||
AnchorSideTop.Control = Z1Edit
|
AnchorSideTop.Control = Z1Edit
|
||||||
@ -115,15 +116,15 @@ object TwozProbForm: TTwozProbForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 4
|
Top = 4
|
||||||
Width = 155
|
Width = 141
|
||||||
Caption = 'The probability between z1 = '
|
Caption = 'The probability between z1'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object Z1Edit: TEdit
|
object Z1Edit: TEdit
|
||||||
AnchorSideLeft.Control = Label1
|
AnchorSideLeft.Control = Label1
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = Panel1
|
||||||
Left = 163
|
Left = 149
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 68
|
Width = 68
|
||||||
@ -137,12 +138,12 @@ object TwozProbForm: TTwozProbForm
|
|||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = Label1
|
AnchorSideRight.Control = Label1
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 107
|
Left = 104
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 48
|
Width = 37
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'and z2 = '
|
Caption = 'and z2 '
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object Z2Edit: TEdit
|
object Z2Edit: TEdit
|
||||||
@ -151,7 +152,7 @@ object TwozProbForm: TTwozProbForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = Z1Edit
|
AnchorSideRight.Control = Z1Edit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 163
|
Left = 149
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 27
|
Top = 27
|
||||||
Width = 68
|
Width = 68
|
||||||
@ -169,9 +170,9 @@ object TwozProbForm: TTwozProbForm
|
|||||||
Left = 84
|
Left = 84
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 66
|
Top = 66
|
||||||
Width = 71
|
Width = 57
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'Probability = '
|
Caption = 'Probability'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ProbEdit: TEdit
|
object ProbEdit: TEdit
|
||||||
@ -180,7 +181,7 @@ object TwozProbForm: TTwozProbForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = Z1Edit
|
AnchorSideRight.Control = Z1Edit
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 163
|
Left = 149
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 62
|
Top = 62
|
||||||
Width = 68
|
Width = 68
|
||||||
|
@ -6,8 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, ExtCtrls,
|
StdCtrls, ExtCtrls;
|
||||||
FunctionsLib;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -27,6 +26,7 @@ type
|
|||||||
Z1Edit: TEdit;
|
Z1Edit: TEdit;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
procedure ComputeBtnClick(Sender: TObject);
|
procedure ComputeBtnClick(Sender: TObject);
|
||||||
|
procedure FormActivate(Sender: TObject);
|
||||||
procedure ResetBtnClick(Sender: TObject);
|
procedure ResetBtnClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
@ -39,6 +39,11 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$R *.lfm}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Math, MathUnit, Utils;
|
||||||
|
|
||||||
{ TTwozProbForm }
|
{ TTwozProbForm }
|
||||||
|
|
||||||
procedure TTwozProbForm.ResetBtnClick(Sender: TObject);
|
procedure TTwozProbForm.ResetBtnClick(Sender: TObject);
|
||||||
@ -49,26 +54,37 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTwozProbForm.ComputeBtnClick(Sender: TObject);
|
procedure TTwozProbForm.ComputeBtnClick(Sender: TObject);
|
||||||
VAR
|
var
|
||||||
z1, z2, prob : double;
|
z1, z2, prob : double;
|
||||||
outvalue : string;
|
|
||||||
begin
|
begin
|
||||||
z1 := StrToFloat(Z1Edit.Text);
|
if not MyTryStrToFloat(Z1Edit.Text, z1) then
|
||||||
z2 := StrToFloat(Z2Edit.Text);
|
begin
|
||||||
if z1 < z2 then
|
Z1Edit.SetFocus;
|
||||||
begin
|
ErrorMsg('No valid number.');
|
||||||
prob := probz(z2) - probz(z1);
|
exit;
|
||||||
end;
|
end;
|
||||||
if z1 > z2 then
|
|
||||||
begin
|
if not MyTryStrToFloat(Z2Edit.Text, z2) then
|
||||||
prob := probz(z1) - probz(z2);
|
begin
|
||||||
end;
|
Z2Edit.SetFocus;
|
||||||
outvalue := format('%6.4f',[prob]);
|
ErrorMsg('No valid number.');
|
||||||
ProbEdit.Text := outvalue;
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
prob := abs(NormalDist(z2) - NormalDist(z1));
|
||||||
|
ProbEdit.Text := Format('%6.4f', [prob]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
procedure TTwozProbForm.FormActivate(Sender: TObject);
|
||||||
{$I twozprobunit.lrs}
|
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.
|
end.
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ function FactorialLn(n: Integer): Double;
|
|||||||
function PoissonPDF(n: integer; a: double): Double;
|
function PoissonPDF(n: integer; a: double): Double;
|
||||||
function PoissonCDF(n: Integer; a: double): Double;
|
function PoissonCDF(n: Integer; a: double): Double;
|
||||||
|
|
||||||
|
function MyTryStrToFloat(S: String; out AValue: Double): Boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -569,6 +570,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ Converts a string to a floating point value. Checks for comma or point as
|
||||||
|
decimal separator }
|
||||||
|
function MyTryStrToFloat(S: String; out AValue: Double): Boolean;
|
||||||
|
var
|
||||||
|
fs: TFormatSettings;
|
||||||
|
begin
|
||||||
|
Result := TryStrToFloat(S, AValue);
|
||||||
|
if not Result then
|
||||||
|
begin
|
||||||
|
fs := FormatSettings;
|
||||||
|
if fs.DecimalSeparator = '.' then fs.DecimalSeparator := ',' else fs.DecimalSeparator := '.';
|
||||||
|
Result := TryStrToFloat(S, AValue, fs);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
InitFactLn();
|
InitFactLn();
|
||||||
|
@ -194,4 +194,3 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user