~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/cdhc/test.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <grass/gis.h>
 
4
#include <grass/cdhc.h>
 
5
#include "local_proto.h"
 
6
 
 
7
int main(int argc, char **argv)
 
8
{
 
9
    double z[1000];
 
10
    double *w;
 
11
    int n = 0;
 
12
 
 
13
    while (scanf("%lf", &z[n++]) != EOF) ;
 
14
    n--;
 
15
 
 
16
    fprintf(stdout, "TESTS:\n");
 
17
    fprintf(stdout, "N:                                                 %d\n", n);
 
18
 
 
19
    fprintf(stdout, "Moments \\sqrt{b_1} and b_2: ");
 
20
    w = Cdhc_omnibus_moments(z, n);
 
21
    fprintf(stdout, "%g %g\n", w[0], w[1]);
 
22
 
 
23
    fprintf(stdout, "Geary's a-statistic & an approx. normal:           ");
 
24
    w = Cdhc_geary_test(z, n);
 
25
    fprintf(stdout, "%g %g\n", w[0], w[1]);
 
26
 
 
27
    fprintf(stdout, "Cdhc_extreme normal deviates:                              ");
 
28
    w = Cdhc_extreme(z, n);
 
29
    fprintf(stdout, "%g %g\n", w[0], w[1]);
 
30
 
 
31
    fprintf(stdout, "D'Agostino's D & an approx. normal:                        ");
 
32
    w = Cdhc_dagostino_d(z, n);
 
33
    fprintf(stdout, "%g %g\n", w[0], w[1]);
 
34
 
 
35
    fprintf(stdout, "Kuiper's V (regular & modified for normality):             ");
 
36
    w = Cdhc_kuipers_v(z, n);
 
37
    fprintf(stdout, "%g %g\n", w[1], w[0]);
 
38
 
 
39
    fprintf(stdout, "Watson's U^2 (regular & modified for normality):   ");
 
40
    w = Cdhc_watson_u2(z, n);
 
41
    fprintf(stdout, "%g %g\n", w[1], w[0]);
 
42
 
 
43
    fprintf(stdout, "Durbin's Exact Test (modified Kolmogorov):         ");
 
44
    w = Cdhc_durbins_exact(z, n);
 
45
    fprintf(stdout, "%g\n", w[0]);
 
46
 
 
47
    fprintf(stdout,
 
48
            "Anderson-Darling's A^2 (regular & modified for normality): ");
 
49
    w = Cdhc_anderson_darling(z, n);
 
50
    fprintf(stdout, "%g %g\n", w[1], w[0]);
 
51
 
 
52
    fprintf(stdout,
 
53
            "Cramer-Von Mises W^2(regular & modified for normality):    ");
 
54
    w = Cdhc_cramer_von_mises(z, n);
 
55
    fprintf(stdout, "%g %g\n", w[1], w[0]);
 
56
 
 
57
    fprintf(stdout,
 
58
            "Kolmogorov-Smirnov's D (regular & modified for normality): ");
 
59
    w = Cdhc_kolmogorov_smirnov(z, n);
 
60
    fprintf(stdout, "%g %g\n", w[1], w[0]);
 
61
 
 
62
    fprintf(stdout, "Chi-Square stat (equal probability classes) and d.f.:      ");
 
63
    w = Cdhc_chi_square(z, n);
 
64
    fprintf(stdout, "%g %d\n", w[0], (int)w[1]);
 
65
    if (n > 50) {
 
66
        G_warning("Shapiro-Wilk's W cannot be used for n > 50");
 
67
        if (n < 99)
 
68
            G_message("Use Weisberg-Binghams's W''");
 
69
    }
 
70
    else {
 
71
        fprintf(stdout, "Shapiro-Wilk W:                                                ");
 
72
        w = Cdhc_shapiro_wilk(z, n);
 
73
        fprintf(stdout, "%g\n", w[0]);
 
74
    }
 
75
 
 
76
    if (n > 99 || n < 50)
 
77
        G_warning
 
78
            ("Weisberg-Bingham's W'' cannot be used for n < 50 or n > 99");
 
79
    else {
 
80
        fprintf(stdout, "Weisberg-Bingham's W'':                        ");
 
81
        w = Cdhc_weisberg_bingham(z, n);
 
82
        fprintf(stdout, "%g\n", w[0]);
 
83
    }
 
84
 
 
85
    if (n > 2000)
 
86
        G_warning("Royston only extended Shapiro-Wilk's W up to n = 2000");
 
87
    else {
 
88
        fprintf(stdout, "Shapiro-Wilk W'':                                      ");
 
89
        w = Cdhc_royston(z, n);
 
90
        fprintf(stdout, "%g\n", w[0]);
 
91
    }
 
92
 
 
93
    fprintf(stdout, "Kotz' T'_f (Lognormality vs. Normality):           ");
 
94
    w = Cdhc_kotz_families(z, n);
 
95
    fprintf(stdout, "%g\n", w[0]);
 
96
 
 
97
    return EXIT_SUCCESS;
 
98
}