Annotation of OpenXM/src/asir-contrib/packages/doc/nk_fb_gen_c/nk_fb_gen_c.oxg, Revision 1.2
1.2 ! takayama 1: $OpenXM: OpenXM/src/asir-contrib/packages/doc/nk_fb_gen_c/nk_fb_gen_c.oxg,v 1.1 2014/03/27 05:24:28 takayama Exp $
1.1 takayama 2: test1.c, test1.h $B$O$3$N%W%m%0%i%`$G@8@.$5$l$?Nc(B. data, $B=i4|CM$O$9$G$K@_Dj:Q(B.
3: /* $B$^$@=q$$$F$J$$(B.
4: begin: include|
5:
6: @include nk_fb_gen_c_intro.ja
7:
8: end:
9: */
10:
11: /* $B$^$@=q$$$F$J$$(B.
12: begin: include|
13:
14: @include nk_fb_gen_c_intro.en
15:
16: end:
17: */
18:
19: /*&usage-ja
20: begin: nk_fb_gen_c.gen_c(N)
21: {N} $B<!85(B Fisher-Bingham $BJ,I[$K$D$$$F$N:GL`?dDj$r(B HGD $BK!(B(holonomic gradient descent) $B$G$d$k$?$a$N(B C $B$N%W%m%0%i%`$r@8@.$9$k(B.
22: description:
23: $B$3$N4X?t$K$h$j(B, testN.c, testN.h $B$J$kFs$D$N(B C $B$N%W%m%0%i%`$,@8@.$5$l$k(B.
24: testN.c $B$K%G!<%?(B, $B:GL`?dDjC5:wMQ$N%Q%i%a!<%?=i4|CM$r@_Dj$9$k(B.
25: $B%3%^%s%I(B
26: @quotation
27: @code{gcc testN.c $OpenXM_HOME/lib/libko_fb.a -lgsl -lblas }
28: @end quotation
29: $B$G<B9T2DG=7A<0$N%U%!%$%k$r:n@.$9$k(B. @*
30: $B$J$*(B,
31: libko_fb.a $B$O(B @file{OpenXM/src/hgm/fisher-bingham/src/} $B$G(B @code{make install} $B$9$k$3$H$K$h$j@8@.$5$l$k(B.
32: $B$^$?%7%9%F%`$K$O(B gsl $B$,%$%s%9%H!<%k$5$l$F$$$J$$$H$$$1$J$$(B.
33: @file{OpenXM/src/hgm/fisher-bingham/src/Testdata} $B$K%5%s%W%k$N(B
34: $B%G!<%?(B, $B:GL`?dDjC5:wMQ$N%Q%i%a!<%?=i4|CM$,$"$k(B. @*
1.2 ! takayama 35: testN.h $B$N(B @code{#define MULTIMIN_FDFMINIMIZER_TYPE} $B$G(B gsl $B$N$I$N:GE,2=4X?t$r8F$S=P$9$+JQ99$G$-$k(B.
! 36: testN.h $B$N(B @code{#define ODEIV_STEP_TYPE} $B$G(B gsl $B$N$I$N>oHyJ,J}Dx<0?tCM2r@O4X?t$r8F$S=P$9$+JQ99$G$-$k(B. @*
1.1 takayama 37: $B%"%k%4%j%:%`$N>\:Y$O(B,
38: T. Koyama, H. Nakayama, K. Nishiyama, N. Takayama, Holonomic Gradient Descent for the Fisher-Bingham Distribution on the d-dimensional Sphere, Computational Statistics (2013),
39: @url{http://dx.doi.org/10.1007/s00180-013-0456-z}
40: $B$r;2>H(B. @*
41: Authors; T.Koyama, H.Nakayama, K.Nishiyama, N.Takayama.
42: example:
43: [1854] load("nk_fb_gen_c.rr");
44: [2186] nk_fb_gen_c.gen_c(1); S^1 $B$NLdBj$r2r$/(B program $B$r@8@.(B.
45: generate test1.h
46: generate test1.c
47: 1
48: [2187] quit;
49: $ emacs test1.c &
50:
51:
52: Write data here.
53: $B$H%3%a%s%H$K=q$+$l$F$$$k$H$3$m$N8e(B
54: $B$K(B $(OpenXM_HOME)/src/hgm/fisher-bingham/Testdata/s1_wind_data.h $B$rA^F~(B.
55: $BJ]B8=*N;(B.
56:
57: $ gcc test1.c $OpenXM_HOME/lib/libko_fb.a -lgsl -lblas
58: $ ./a.out
59: --- snip
60: points = [1.11945, 3.33044, -0.469454, 0.904504, -0.770373]
61: values = [3.4421, 1.13891, -0.0217944, 2.28474]
62: grad ; 0.005644 -0.033429 -0.005644 0.045820 0.047695
63: norm(grad) ; 0.074535
64: --- snip
65:
66: $B$3$3$G(B, points $B$,(B parameter x11,x12,x22,y1,y2 $B$N?dDjCM(B.
67: Value 3.4421 $B$,(B $BL`EYCM$N5U?t$G(B, $B$3$l$,:G>.2=$5$l$F$$$k(B.
68: end:
69: */
70:
71: /*&usage-en
72: begin: nk_fb_gen_c.gen_c(N)
73: It generates a C program to make a MLE (maximal likelihood estimate)
74: by the HGD (holonomic gradient descent)
75: for {N} dimensional Fisher-Bingham distribution.
76: description:
77: This function generates two C programs testN.c and testN.h.
78: After setting data and an initial point to make MLE in testN.c,
79: build an executable file by the command
80: @quotation
81: @code{gcc testN.c $OpenXM_HOME/lib/libko_fb.a -lgsl -lblas }
82: @end quotation
83: The libray file libko_fb.a is generated by
84: @code{make install} in the folder @file{OpenXM/src/hgm/fisher-bingham/src/}
85: The GSL (Gnu Scientific Library) should also be installed in the system.
86: Sample data and initial points are in @file{OpenXM/src/hgm/fisher-bingham/src/Testdata}.
87: @*
1.2 ! takayama 88: The definition @code{#define MULTIMIN_FDFMINIMIZER_TYPE} in testN.h specifies
! 89: an optimization problem solver of gsl.
! 90: The definition @code{#define ODEIV_STEP_TYPE} in testN.h specifies a solver of the ordinary differential
! 91: equation of gsl. @*
1.1 takayama 92: As to the algorithm, refer to
93: T. Koyama, H. Nakayama, K. Nishiyama, N. Takayama, Holonomic Gradient Descent for the Fisher-Bingham Distribution on the d-dimensional Sphere, Computational Statistics (2013),
94: @url{http://dx.doi.org/10.1007/s00180-013-0456-z} @*
95: Authors; T.Koyama, H.Nakayama, K.Nishiyama, N.Takayama.
96: example:
97: [1854] load("nk_fb_gen_c.rr");
98: [2186] nk_fb_gen_c.gen_c(1); Generate a program to solve MLE on S^1
99: generate test1.h
100: generate test1.c
101: 1
102: [2187] quit;
103: $ emacs test1.c &
104:
105: Find a line which contains
106: Write data here
107: and insert $(OpenXM_HOME)/src/hgm/fisher-bingham/Testdata/s1_wind_data.h.
108: after this line.
109: Save and quit emacs.
110:
111: $ gcc test1.c $OpenXM_HOME/lib/libko_fb.a -lgsl -lblas
112: $ ./a.out
113: --- snip
114: points = [1.11945, 3.33044, -0.469454, 0.904504, -0.770373]
115: values = [3.4421, 1.13891, -0.0217944, 2.28474]
116: grad ; 0.005644 -0.033429 -0.005644 0.045820 0.047695
117: norm(grad) ; 0.074535
118: --- snip
119:
120: where ``points'' is the estimated value of the parameter x11,x12,x22,y1,y2.
121: Value 3.4421 is the inverse of the likelihood which is minimized.
122: end:
123: */
124:
125:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>