Child: [d2cf75] (diff)

Download this file

StatLib.def    170 lines (150 with data), 11.2 kB

  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
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
DEFINITION MODULE StatLib;
(*------------------------------------------------------------------------*)
(* Modul fuer einige Statistikfunktionen. *)
(* Modul for some statistical functions. *)
(*------------------------------------------------------------------------*)
(* Implementation : Michael Riedl *)
(* Licence : GNU Lesser General Public License (LGPL) *)
(*------------------------------------------------------------------------*)
(* $Id: StatLib.def,v 1.4 2015/10/09 07:34:32 mriedl Exp $ *)
PROCEDURE CDF(x : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* Kummulative Verteilungsfunktion d. Standartverteilungsfunktion *)
(* Cumulative Distribution Function *)
(* *)
(* Calculates the probability integral *)
(* *)
(* $cdf(x) = {1 \over {2\pi}} \int_{-\inf}^x exp{-\half x^2} dx$ *)
(* *)
(* of the standard normal distribution *)
(*----------------------------------------------------------------*)
PROCEDURE InvProbInt(p : LONGREAL;
genau : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* InvProbInt = Inverses Wahrscheinlichekitsintegal *)
(* Berechnet aus dem normierte Wahrscheinlichkeitsintegral *)
(* *)
(* \Phi(x) = {1 \over \sqrt{2\pi} *)
(* \int_{-\inf}^x exp{-\half x^2} *)
(* *)
(* dasjenige x_p, f"ur das \Phi(x_p) = p *)
(* *)
(* Die Genauigkeit der Routine duerft bei ca. 4-5 Stellen liegen *)
(* *)
(* Auch : Quantil der Standartnormalverteilung (typische Werte) *)
(* *)
(* 0.750 0.67449 | 0.800 0.84162 | 0.900 1.28155 | 0.950 1.64485 *)
(* 0.975 1.95996 | 0.990 2.32635 | 0.995 2.57583 | 0.999 3.09023 *)
(* *)
(* https://en.wikipedia.org/wiki/Quantile_function *)
(* https://de.wikipedia.org/wiki/Tabelle_Standardnormalverteilung *)
(* *)
(* This function calculates the inverse of the probability *)
(* integral for \Phi(x) (see formula above). *)
(* *)
(* This function is the invers of the CDF function given in this *)
(* module, if you plot x,CDF(x) and InvProbInt(x),x that should *)
(* be approximately the same line. This function should be exact *) (* to about 4-5 decimal digits in the worst case. *)
(*----------------------------------------------------------------*)
PROCEDURE StudentT(n : CARDINAL;
Alpha : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* Berechnet den Studentschen t-Koeffizenten f"ur n *)
(* Freiheitsgrade und statistischer Sicherheit Alpha. *)
(*----------------------------------------------------------------*)
PROCEDURE Fisher(m,n : INTEGER;
x : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* Based on ACM Algorithm 322 *)
(* *)
(* Probabilities in several variance distributions *)
(* *)
(* References: *)
(* Egon Dorrer, "Algorithm 322: F-Distribution [S14]", *)
(* Communications of the ACM, Vol 11(2), 1968, p116-117. *)
(* *)
(* Probabilities are returned as the integral of P(q)dq for q *)
(* in the range zero to X (F-ratio and chi-square) or from *)
(* -X to +X (Student's t and Normal). *)
(* *)
(* For F-ratios: *)
(* M = numerator degrees of freedom *)
(* N = denominator degrees of freedom *)
(* X = F-ratio *)
(* For Student's t (two tailed): *)
(* M = 1 *)
(* N = Degrees of freedom *)
(* X = The square of t *)
(* For normal deviates (two tailed): *)
(* M = 1 *)
(* N = 5000 *)
(* X = The square of the deviate *)
(* For chi-square: *)
(* M = Degrees of freedom *)
(* N = 5000 *)
(* X = Chi-square/M *)
(* *)
(* The returned probability will be in the range 0 to 1, unless *)
(* an error occurred, in which case -1.0 is returned. *)
(* Recoded by LW, 28-Mar-94. *)
(*----------------------------------------------------------------*)
PROCEDURE FisherM2(VAR m,n : INTEGER;
VAR x : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* VAR m,n,x wg. FORTRAN, wird nur in der Testroutine benoetigt, *)
(* nicht zu direkten Gebrauch. *)
(* Not for direct use - needed only in the Fortran test routine *)
(*----------------------------------------------------------------*)
PROCEDURE Student(df : INTEGER;
t : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* Call to Fisher with M=1, N=degrees of freedom, x=t**2 *)
(*----------------------------------------------------------------*)
PROCEDURE InvNorm(P : LONGREAL) : LONGREAL;
(*----------------------------------------------------------------*)
(* Inverse normal cumulative distribution function. *)
(* Relative error less than 1.15��10���9 in the interval (0,0.97575) *)
(* *)
(* Derived from FORTRAN IV code of Ren-Raw Chen, rutgers business *)
(* school, based on an algorith of Peter John Acklam *)
(* *)
(* For details see: *)
(* *)
(* http://home.online.no/~pjacklam/notes/invnorm *)
(* *)
(*----------------------------------------------------------------*)
PROCEDURE Wilcoxon(VAR X,Y : ARRAY OF LONGREAL;
nx,ny : CARDINAL;
Alpha : LONGREAL;
VAR NInv : CARDINAL;
VAR Uxy,Ua : LONGREAL;
VAR iFehl : CARDINAL) : BOOLEAN;
(*----------------------------------------------------------------*)
(* Wilcoxon - Test. (Status Beta) *)
(* *)
(* Dient der Pruefung der Hypothese, ob zwei Stichproben X und Y *)
(* vom Umfang nx bzw. ny zum Signifikanzniveau Alpha ein und *)
(* derselben Grundgesamtheit entstammen. Ist die der Fall, gibt *)
(* die Routine TRUE zurueck, ansonsten FALSE. *)
(* Vorgaben fuer die kritischen Werte sind fuer ny+ny < 50 *)
(* und Alpha = 0,10 | 0.05 | 0.02 | 0.01 hinterlegt. *)
(* *)
(* Lit. : Bronstein, I.N.; Semendjaev, K.A.; 'Taschenbuch der *)
(* Mathematik', Teubner, Leipzig (DDR), 1985. *)
(* *)
(* X : erste Stichprobe mit nx Elementen *)
(* Y : zweite Stichprobe mit ny Elementen *)
(* Alpha : statistischer Sicherheit *)
(* NInv : Anzahl der Inversionen *)
(* Uxy : ABS(((nx*ny / 2) - Anzahl der Inversionen) *)
(* Ua : kritischer Wert (aus Tabelle oder berechnet) *)
(* iFehl = 1 : Kein Vorgabewert fuer den kritischen Wert fuer *)
(* gewaehltes Alpha *)
(* 2 : Berechneter kritischer Wert fuer kleine Proben- *)
(* groesse da kein Vorgabewert vorhanden. *)
(* 98 : Speicherallokationsfehler. *)
(* 99 : Interner Fehler - sollte nicht vorkommen *)
(* *)
(* Fuer IFehl # 0 wird Errors.Fehlerflag entsprechend gesetzt. *)
(*----------------------------------------------------------------*)
END StatLib.