GRASS 8 Programmer's Manual
8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
shapiro2.c
Go to the documentation of this file.
1
#include <
stdio.h
>
2
#include <
stdlib.h
>
3
#include <math.h>
4
#include "local_proto.h"
5
6
/* this is actually the Weisberg-Bingham stat. I need to
7
OCR the constants and implement this Cdhc_correctly */
8
9
double
*
Cdhc_shapiro_francia
(
double
*x,
int
n)
10
{
11
static
double
y[2];
12
double
suma
= 0.0,
sumb
= 0.0,
sumc
= 0.0,
sumd
= 0.0, z, *
xcopy
;
13
int
i;
14
15
if
((
xcopy
= (
double
*)
malloc
(n *
sizeof
(
double
))) ==
NULL
) {
16
fprintf
(
stderr
,
"Memory error in Cdhc_shapiro_francia\n"
);
17
exit
(
EXIT_FAILURE
);
18
}
19
20
for
(i = 0; i < n; ++i)
21
xcopy
[i] =
x
[i];
22
23
qsort
(
xcopy
, n,
sizeof
(
double
),
Cdhc_dcmp
);
24
25
for
(i = 0; i < n; ++i) {
26
z =
Cdhc_xinormal
((i + 1 - 0.375) / (n + 0.25));
27
suma
+= z *
xcopy
[i];
28
sumb
+= z * z;
29
sumc
+=
xcopy
[i];
30
sumd
+=
xcopy
[i] *
xcopy
[i];
31
}
32
33
y[0] =
suma
*
suma
/
sumb
/ (
sumd
-
sumc
*
sumc
/ n);
34
35
#ifdef NOISY
36
fprintf
(
stdout
,
" TEST14 SF(N) =%10.4f\n"
, y[0]);
37
#endif
/* NOISY */
38
39
free
(
xcopy
);
40
41
return
y;
42
}
/* test14_ */
NULL
#define NULL
Definition
ccmath.h:32
AMI_STREAM
Definition
ami_stream.h:153
Cdhc_dcmp
int Cdhc_dcmp(const void *i, const void *j)
Definition
dcmp.c:1
Cdhc_xinormal
double Cdhc_xinormal(double)
Definition
xinormal.c:4
Cdhc_shapiro_francia
double * Cdhc_shapiro_francia(double *x, int n)
Definition
shapiro2.c:9
malloc
void * malloc(unsigned)
free
void free(void *)
stdio.h
stdlib.h
x
#define x
lib
cdhc
shapiro2.c
Generated on Fri Apr 3 2026 06:59:52 for GRASS 8 Programmer's Manual by
1.9.8