File: test.c

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (110 lines) | stat: -rw-r--r-- 3,380 bytes parent folder | download | duplicates (2)
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
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/cdhc.h>
#include "local_proto.h"

int main(void)
{
    double z[1000];
    double *w;
    int n = 0;

    while (scanf("%lf", &z[n++]) != EOF)
        ;
    n--;

    fprintf(stdout, "TESTS:\n");
    fprintf(stdout,
            "N:                                                        %d\n",
            n);

    fprintf(stdout, "Moments \\sqrt{b_1} and b_2: ");
    w = Cdhc_omnibus_moments(z, n);
    fprintf(stdout, "%g %g\n", w[0], w[1]);

    fprintf(stdout, "Geary's a-statistic & an approx. normal:                ");
    w = Cdhc_geary_test(z, n);
    fprintf(stdout, "%g %g\n", w[0], w[1]);

    fprintf(stdout,
            "Cdhc_extreme normal deviates:                                ");
    w = Cdhc_extreme(z, n);
    fprintf(stdout, "%g %g\n", w[0], w[1]);

    fprintf(stdout,
            "D'Agostino's D & an approx. normal:                        ");
    w = Cdhc_dagostino_d(z, n);
    fprintf(stdout, "%g %g\n", w[0], w[1]);

    fprintf(stdout,
            "Kuiper's V (regular & modified for normality):                ");
    w = Cdhc_kuipers_v(z, n);
    fprintf(stdout, "%g %g\n", w[1], w[0]);

    fprintf(stdout, "Watson's U^2 (regular & modified for normality):        ");
    w = Cdhc_watson_u2(z, n);
    fprintf(stdout, "%g %g\n", w[1], w[0]);

    fprintf(stdout,
            "Durbin's Exact Test (modified Kolmogorov):                ");
    w = Cdhc_durbins_exact(z, n);
    fprintf(stdout, "%g\n", w[0]);

    fprintf(
        stdout,
        "Anderson-Darling's A^2 (regular & modified for normality):        ");
    w = Cdhc_anderson_darling(z, n);
    fprintf(stdout, "%g %g\n", w[1], w[0]);

    fprintf(stdout,
            "Cramer-Von Mises W^2(regular & modified for normality):        ");
    w = Cdhc_cramer_von_mises(z, n);
    fprintf(stdout, "%g %g\n", w[1], w[0]);

    fprintf(
        stdout,
        "Kolmogorov-Smirnov's D (regular & modified for normality):        ");
    w = Cdhc_kolmogorov_smirnov(z, n);
    fprintf(stdout, "%g %g\n", w[1], w[0]);

    fprintf(stdout,
            "Chi-Square stat (equal probability classes) and d.f.:        ");
    w = Cdhc_chi_square(z, n);
    fprintf(stdout, "%g %d\n", w[0], (int)w[1]);
    if (n > 50) {
        G_warning("Shapiro-Wilk's W cannot be used for n > 50");
        if (n < 99)
            G_message("Use Weisberg-Binghams's W''");
    }
    else {
        fprintf(
            stdout,
            "Shapiro-Wilk W:                                                ");
        w = Cdhc_shapiro_wilk(z, n);
        fprintf(stdout, "%g\n", w[0]);
    }

    if (n > 99 || n < 50)
        G_warning("Weisberg-Bingham's W'' cannot be used for n < 50 or n > 99");
    else {
        fprintf(stdout, "Weisberg-Bingham's W'':                        ");
        w = Cdhc_weisberg_bingham(z, n);
        fprintf(stdout, "%g\n", w[0]);
    }

    if (n > 2000)
        G_warning("Royston only extended Shapiro-Wilk's W up to n = 2000");
    else {
        fprintf(stdout,
                "Shapiro-Wilk W'':                                        ");
        w = Cdhc_royston(z, n);
        fprintf(stdout, "%g\n", w[0]);
    }

    fprintf(stdout, "Kotz' T'_f (Lognormality vs. Normality):                ");
    w = Cdhc_kotz_families(z, n);
    fprintf(stdout, "%g\n", w[0]);

    return EXIT_SUCCESS;
}