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

« back to all changes in this revision

Viewing changes to lib/cdhc/as177.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:
6
6
 *
7
7
 * Translation to C by James Darrell McCauley, mccauley@ecn.purdue.edu.
8
8
 *
9
 
 * The functions nscor1() and nscor2() calculate the expected values of
 
9
 * The functions Cdhc_nscor1() and Cdhc_nscor2() calculate the expected values of
10
10
 * normal order statistics in exact or approximate form, respectively.
11
11
 *
12
12
 */
20
20
 
21
21
 
22
22
/* Local function prototypes */
23
 
static double alnfac(int j);
24
 
static double correc(int i, int n);
 
23
static double Cdhc_alnfac(int j);
 
24
static double Cdhc_correc(int i, int n);
25
25
 
26
26
 
27
27
/* exact calculation of normal scores */
28
 
void nscor1(double s[], int n, int n2, double work[], int *ifault)
 
28
void Cdhc_nscor1(double s[], int n, int n2, double work[], int *ifault)
29
29
{
30
30
    double ani, c, c1, d, scor;
31
31
    int i, j;
43
43
        *ifault = 2;
44
44
 
45
45
    /* calculate the natural log of factorial(n) */
46
 
    c1 = alnfac(n);
 
46
    c1 = Cdhc_alnfac(n);
47
47
    d = c1 - log((double)n);
48
48
 
49
49
    /* accumulate ordinates for calculation of integral for rankits */
73
73
    for (i = 0; i < NSTEP; ++i) {
74
74
        work[0 * NSTEP + i] = xx;
75
75
        work[1 * NSTEP + i] = pi2 - xx * xx * 0.5;
76
 
        work[2 * NSTEP + i] = log(alnorm(xx, 1));
77
 
        work[3 * NSTEP + i] = log(alnorm(xx, 0));
 
76
        work[2 * NSTEP + i] = log(Cdhc_alnorm(xx, 1));
 
77
        work[3 * NSTEP + i] = log(Cdhc_alnorm(xx, 0));
78
78
        xx = xstart + H * (i + 1.0);
79
79
    }
80
80
 
85
85
/*-Algorithm AS 177.2 Appl. Statist. (1982) Vol.31, No.2
86
86
 * Natural logarithm of factorial for non-negative argument
87
87
 */
88
 
static double alnfac(int j)
 
88
static double Cdhc_alnfac(int j)
89
89
{
90
90
    static double r[7] = { 0.0, 0.0, 0.69314718056, 1.79175946923,
91
91
        3.17805383035, 4.78749174278, 6.57925121101
108
108
/*-Algorithm AS 177.3 Appl. Statist. (1982) Vol.31, No.2
109
109
 * Approximation for Rankits
110
110
 */
111
 
void nscor2(double s[], int n, int n2, int *ifault)
 
111
void Cdhc_nscor2(double s[], int n, int n2, int *ifault)
112
112
{
113
113
    static double eps[4] = { 0.419885, 0.450536, 0.456936, 0.468488 };
114
114
    static double dl1[4] = { 0.112063, 0.121770, 0.239299, 0.215159 };
140
140
    for (i = 0; i < k; ++i) {
141
141
        e1 = (1.0 + i - eps[i]) / (n + gam[i]);
142
142
        e2 = pow(e1, lam[i]);
143
 
        s[i] = e1 + e2 * (dl1[i] + e2 * dl2[i]) / n - correc(1 + i, n);
 
143
        s[i] = e1 + e2 * (dl1[i] + e2 * dl2[i]) / n - Cdhc_correc(1 + i, n);
144
144
    }
145
145
 
146
146
    if (n2 != k) {
149
149
            l1 = lam[3] + bb / (1.0 + i + d);
150
150
            e1 = (1.0 + i - eps[3]) / (n + gam[3]);
151
151
            e2 = pow(e1, l1);
152
 
            s[i] = e1 + e2 * (dl1[3] + e2 * dl2[3]) / n - correc(1 + i, n);
 
152
            s[i] = e1 + e2 * (dl1[3] + e2 * dl2[3]) / n - Cdhc_correc(1 + i, n);
153
153
        }
154
154
    }
155
155
 
162
162
 
163
163
 
164
164
/*-Algorithm AS 177.4 Appl. Statist. (1982) Vol.31, No.2
165
 
 * Calculates correction for tail area of noraml distribution
 
165
 * Calculates Cdhc_correction for tail area of noraml distribution
166
166
 * corresponding to ith largest rankit in sample size n.
167
167
 */
168
 
static double correc(int i, int n)
 
168
static double Cdhc_correc(int i, int n)
169
169
{
170
170
    static double c1[7] = { 9.5, 28.7, 1.9, 0.0, -7.0, -6.2, -1.6 };
171
171
    static double c2[7] = { -6.195e3, -9.569e3, -6.728e3, -17.614e3,