Annotation of OpenXM/src/asir-contrib/packages/doc/nk_fb_gen_c/nk_fb_gen_c.oxg, Revision 1.3
1.3 ! takayama 1: $OpenXM: OpenXM/src/asir-contrib/packages/doc/nk_fb_gen_c/nk_fb_gen_c.oxg,v 1.2 2014/04/03 07:34:30 takayama Exp $
! 2: test1.c, test1.h はこのプログラムで生成された例. data, 初期値はすでに設定済.
! 3: /* まだ書いてない.
1.1 takayama 4: begin: include|
5:
6: @include nk_fb_gen_c_intro.ja
7:
8: end:
9: */
10:
1.3 ! takayama 11: /* まだ書いてない.
1.1 takayama 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)
1.3 ! takayama 21: {N} 次元 Fisher-Bingham 分布についての最尤推定を HGD 法(holonomic gradient descent) でやるための C のプログラムを生成する.
1.1 takayama 22: description:
1.3 ! takayama 23: この関数により, testN.c, testN.h なる二つの C のプログラムが生成される.
! 24: testN.c にデータ, 最尤推定探索用のパラメータ初期値を設定する.
! 25: コマンド
1.1 takayama 26: @quotation
27: @code{gcc testN.c $OpenXM_HOME/lib/libko_fb.a -lgsl -lblas }
28: @end quotation
1.3 ! takayama 29: で実行可能形式のファイルを作成する. @*
! 30: なお,
! 31: libko_fb.a は @file{OpenXM/src/hgm/fisher-bingham/src/} で @code{make install} することにより生成される.
! 32: またシステムには gsl がインストールされていないといけない.
! 33: @file{OpenXM/src/hgm/fisher-bingham/src/Testdata} にサンプルの
! 34: データ, 最尤推定探索用のパラメータ初期値がある. @*
! 35: testN.h の @code{#define MULTIMIN_FDFMINIMIZER_TYPE} で gsl のどの最適化関数を呼び出すか変更できる.
! 36: testN.h の @code{#define ODEIV_STEP_TYPE} で gsl のどの常微分方程式数値解析関数を呼び出すか変更できる. @*
! 37: アルゴリズムの詳細は,
1.1 takayama 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}
1.3 ! takayama 40: を参照. @*
1.1 takayama 41: Authors; T.Koyama, H.Nakayama, K.Nishiyama, N.Takayama.
42: example:
43: [1854] load("nk_fb_gen_c.rr");
1.3 ! takayama 44: [2186] nk_fb_gen_c.gen_c(1); S^1 の問題を解く program を生成.
1.1 takayama 45: generate test1.h
46: generate test1.c
47: 1
48: [2187] quit;
49: $ emacs test1.c &
50:
51:
52: Write data here.
1.3 ! takayama 53: とコメントに書かれているところの後
! 54: に $(OpenXM_HOME)/src/hgm/fisher-bingham/Testdata/s1_wind_data.h を挿入.
! 55: 保存終了.
1.1 takayama 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:
1.3 ! takayama 66: ここで, points が parameter x11,x12,x22,y1,y2 の推定値.
! 67: Value 3.4421 が 尤度値の逆数で, これが最小化されている.
1.1 takayama 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>