GRASS 8 Programmer's Manual
8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
andrsnde.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
double
*
Cdhc_anderson_darling_exp
(
double
*x,
int
n)
7
{
8
static
double
y[2];
9
double
mean
= 0.0, *
xcopy
,
fx
,
sum3
= 0.0;
10
int
i;
11
12
if
((
xcopy
= (
double
*)
malloc
(n *
sizeof
(
double
))) ==
NULL
) {
13
fprintf
(
stderr
,
"Memory error in Cdhc_anderson_darling\n"
);
14
exit
(
EXIT_FAILURE
);
15
}
16
17
for
(i = 0; i < n; ++i) {
18
xcopy
[i] =
x
[i];
19
mean
+=
x
[i];
20
}
21
mean
/= n;
22
qsort
(
xcopy
, n,
sizeof
(
double
),
Cdhc_dcmp
);
23
24
for
(i = 0; i < n; ++i) {
25
fx
= 1 -
exp
(-
xcopy
[i] /
mean
);
26
sum3
+= (2.0 * i + 1) * (
log
(
fx
) -
xcopy
[n - i - 1] /
mean
);
27
}
28
29
y[0] = (1.0 + 0.3 / n) * (-n -
sum3
/ n);
30
#ifdef NOISY
31
fprintf
(
stdout
,
" TEST20 AD(E) =%10.4f\n"
, y[0]);
32
#endif
/* NOISY */
33
34
free
(
xcopy
);
35
36
return
y;
37
}
Cdhc_anderson_darling_exp
double * Cdhc_anderson_darling_exp(double *x, int n)
Definition
andrsnde.c:6
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
mean
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
Definition
iclass_statistics.c:369
malloc
void * malloc(unsigned)
free
void free(void *)
stdio.h
stdlib.h
x
#define x
lib
cdhc
andrsnde.c
Generated on Fri Apr 3 2026 06:59:52 for GRASS 8 Programmer's Manual by
1.9.8