updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / rlab2 / parzen.diff
blob6b940661bcb29bf680b1ef24d6a0f37a0e834dbc
1 --- rlab-2.2.9-old/clibs/sprannlib/src/stat/parzen.c 2006-07-20 18:00:45.000000000 -0400
2 +++ rlab-2.2.9/clibs/sprannlib/src/stat/parzen.c 2006-11-16 00:32:51.000000000 -0500
3 @@ -408,6 +408,37 @@
6 /*
7 + * FUNC Calculate the criterion function.
8 + */
10 +static double func (double s)
12 + double sk, fc, f, ff, p, dis;
13 + int i, j;
15 + sk = -1.0 / (2.0 * s * s);
16 + fc = 0.0;
18 + for (i = 0; i < size; i++)
19 + {
20 + for (f = ff = j = 0; j < size; j++)
21 + {
22 + if (i != j)
23 + {
24 + dis = d(i, j);
25 + p = exp((double) (sk * dis));
26 + f += p;
27 + ff += dis * p;
28 + }
29 + }
30 + fc += ff / (f * s * s);
31 + }
32 + fc -= (double) (size * dim);
34 + return fc;
37 +/*
38 * PARZEN_BEST_S Calculate optimal value of parzen smoothing parameter s for
39 * a certain class. It uses the following inputs:
41 @@ -465,37 +496,6 @@
42 return s3;
45 -/*
46 - * FUNC Calculate the criterion function.
47 - */
49 -static double func (double s)
51 - double sk, fc, f, ff, p, dis;
52 - int i, j;
54 - sk = -1.0 / (2.0 * s * s);
55 - fc = 0.0;
57 - for (i = 0; i < size; i++)
58 - {
59 - for (f = ff = j = 0; j < size; j++)
60 - {
61 - if (i != j)
62 - {
63 - dis = d(i, j);
64 - p = exp((double) (sk * dis));
65 - f += p;
66 - ff += dis * p;
67 - }
68 - }
69 - fc += ff / (f * s * s);
70 - }
71 - fc -= (double) (size * dim);
73 - return fc;
76 #undef PARZEN