GRASS GIS 7 Programmer's Manual
7.8.2(2019)-exported
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
7
/* this is actually the Weisberg-Bingham stat. I need to
8
OCR the constants and implement this Cdhc_correctly */
9
10
double
*
Cdhc_shapiro_francia
(
double
*
x
,
int
n)
11
{
12
static
double
y[2];
13
double
suma = 0.0, sumb = 0.0, sumc = 0.0, sumd = 0.0, z, *xcopy;
14
int
i;
15
16
if
((xcopy = (
double
*)malloc(n *
sizeof
(
double
))) ==
NULL
) {
17
fprintf(stderr,
"Memory error in Cdhc_shapiro_francia\n"
);
18
exit(EXIT_FAILURE);
19
}
20
21
for
(i = 0; i < n; ++i)
22
xcopy[i] =
x
[i];
23
24
qsort(xcopy, n,
sizeof
(
double
),
Cdhc_dcmp
);
25
26
for
(i = 0; i < n; ++i) {
27
z =
Cdhc_xinormal
((i + 1 - 0.375) / (n + 0.25));
28
suma += z * xcopy[i];
29
sumb += z * z;
30
sumc += xcopy[i];
31
sumd += xcopy[i] * xcopy[i];
32
}
33
34
y[0] = suma * suma / sumb / (sumd - sumc * sumc / n);
35
36
#ifdef NOISY
37
fprintf(stdout,
" TEST14 SF(N) =%10.4f\n"
, y[0]);
38
#endif
/* NOISY */
39
40
free(xcopy);
41
42
return
y;
43
}
/* test14_ */
x
#define x
Cdhc_dcmp
int Cdhc_dcmp(const void *i, const void *j)
Definition:
dcmp.c:1
NULL
#define NULL
Definition:
ccmath.h:32
Cdhc_shapiro_francia
double * Cdhc_shapiro_francia(double *x, int n)
Definition:
shapiro2.c:10
Cdhc_xinormal
double Cdhc_xinormal(double pee)
Definition:
xinormal.c:5
cdhc
shapiro2.c
Generated on Tue Dec 24 2019 19:34:28 for GRASS GIS 7 Programmer's Manual by
1.8.16