File: usnedeco.pas

package info (click to toggle)
mricron 0.20140804.1~dfsg.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,480 kB
  • ctags: 8,011
  • sloc: pascal: 114,853; sh: 49; makefile: 32
file content (53 lines) | stat: -rwxr-xr-x 1,420 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ ******************************************************************
  Snedecor's F-test (comparison of two variances)
  ****************************************************************** }

unit usnedeco;

interface

uses
  utypes;

procedure Snedecor(N1, N2         : Integer;
                   S1, S2         : Float;
                   var F          : Float;
                   var DoF1, DoF2 : Integer);
{ ------------------------------------------------------------------
  Snedecor's F-test (comparison of two variances)
  ------------------------------------------------------------------
  Input parameters : N1, N2     = samples sizes
                     S1, S2     = samples SD's (computed with StDev)
  Output parameters: F          = Snedecor's F
                     DoF1, DoF2 = degrees of freedom
  ------------------------------------------------------------------ }

implementation

procedure Snedecor(N1, N2         : Integer;
                   S1, S2         : Float;
                   var F          : Float;
                   var DoF1, DoF2 : Integer);

var
  V1, V2 : Float;  { Sample variances }

begin
  V1 := Sqr(S1);
  V2 := Sqr(S2);

  if V1 > V2 then
    begin
      F := V1 / V2;
      DoF1 := N1 - 1;
      DoF2 := N2 - 1;
    end
  else
    begin
      F := V2 / V1;
      DoF1 := N2 - 1;
      DoF2 := N1 - 1;
    end;
end;

end.