Annotation of OpenXM/src/asir-contrib/packages/doc/gtt_ekn/gtt_ekn-en.texi, Revision 1.3
1.3 ! takayama 1: %% $OpenXM: OpenXM/src/asir-contrib/packages/doc/gtt_ekn/gtt_ekn-en.texi,v 1.2 2019/06/12 05:53:29 takayama Exp $
1.2 takayama 2: %% xetex gtt_ekn-en.texi (.texi までつける. )
3: %% 英語版, 以下コメントは @comment で始める. \input texinfo 以降は普通の tex 命令は使えない.
4: \input texinfo-ja
1.1 takayama 5: @iftex
6: @catcode`@#=6
1.2 takayama 7: @def@fref#1{@xrefX[#1,,@code{#1},,,]}
8: @def@b#1{{@bf #1}}
1.1 takayama 9: @catcode`@#=@other
10: @end iftex
11: @overfullrule=0pt
1.2 takayama 12: @documentlanguage en
13: @c -*-texinfo-*-
14: @comment %**start of header
15: @comment --- おまじない終り ---
16:
17: @comment --- GNU info ファイルの名前 ---
18: @setfilename xyzman
19:
20: @comment --- タイトル ---
21: @settitle HGM for two way contingency table
22:
23: @comment %**end of header
24: @comment %@setchapternewpage odd
25:
26: @comment --- おまじない ---
27: @ifinfo
28: @macro fref{name}
29: @ref{\name\,,@code{\name\}}
30: @end macro
31: @end ifinfo
32:
33: @iftex
34: @comment @finalout
35: @end iftex
36:
1.1 takayama 37: @titlepage
1.2 takayama 38: @comment --- おまじない終り ---
39:
40: @comment --- タイトル, バージョン, 著者名, 著作権表示 ---
41: @title HGM functions for two way contingency tables.
42: @subtitle HGM functions for two way contingency tables on Risa/Asir
43: @subtitle Version 3.0
1.3 ! takayama 44: @subtitle June 12, 2019
1.2 takayama 45:
46: @author by Y.Goto, Y.Tachibana, N.Takayama
47: @page
48: @vskip 0pt plus 1filll
49: Copyright @copyright{} Risa/Asir committers
50: 2004--2019. All rights reserved.
1.1 takayama 51: @end titlepage
52:
1.2 takayama 53: @comment --- おまじない ---
1.1 takayama 54: @synindex vr fn
1.2 takayama 55: @comment --- おまじない終り ---
56:
57: @comment --- @node は GNU info, HTML 用 ---
58: @comment --- @node の引数は node-name, next, previous, up ---
1.1 takayama 59: @node Top,, (dir), (dir)
60:
1.2 takayama 61: @comment --- @menu は GNU info, HTML 用 ---
62: @comment --- chapter 名を正確に並べる ---
63: @comment --- この文書では chapter XYZ, Chapter Index がある.
64: @comment --- Chapter XYZ には section XYZについて, section XYZに関する関数がある.
1.1 takayama 65: @menu
1.2 takayama 66: * About this document::
67: * Functions of HGM for two way contingency tables::
68: * Modular method
69: * Binary splitting
1.1 takayama 70: * Index::
71: @end menu
72:
1.2 takayama 73: @comment --- chapter の開始 ---
74: @comment --- 親 chapter 名を正確に. 親がない場合は Top ---
75: @node About this document,,, Top
76: @chapter About this document
77:
78: This document explains Risa/Asir functions for two way contingency
79: tables by
80: HGM(holonomic gradient method).
81: Loading the package:
82: @example
83: import("gtt_ekn3.rr");
84: @end example
85: The package gtt_ekn3.rr is a major version up of gtt_ekn.rr.
86: @noindent
87: In order to download the latest asir-contrib package,
88: please use the asir_contrib_update() as follows.
89: @example
90: import("names.rr");
91: asir_contrib_update(|update=1);
92: @end example
93: @noindent
94: References cited in this document.
95: @itemize @bullet
96: @item [GM2016]
97: Y.Goto, K.Matsumoto, Pfaffian equations and contiguity relations of the hypergeometric function of type (k+1,k+n+2) and their applications,
98: @uref{http://arxiv.org/abs/1602.01637,arxiv:1602.01637 (version 1)}
99: @item [T2016]
100: Y.Tachibana, difference holonomic gradient method by the modular method.
101: 2016, master thesis of Kobe University (in Japanese).
102: @item [GTT2016]
103: Y.Goto, Y.Tachibana, N.Takayama,
104: implementation of difference holonomic gradient method for two way contingency tables.
105: RIMS kokyuroku (in Japanese).
106: @item [TGKT]
107: Y.Tachibana, Y.Goto, T.Koyama, N.Takayama,
108: Holonomic Gradient Method for Two Way Contingency Tables,
1.3 ! takayama 109: @uref{https://arxiv.org/abs/1803.04170, arxiv:1803.04170 (the 3rd version)}
1.2 takayama 110: @item [TKT2015]
111: N.Takayama, S.Kuriki, A.Takemura,
112: A-hypergeometric distributions and Newton polytopes.
113: @uref{http://arxiv.org/abs/1510.02269,arxiv:1510.02269}
114: @end itemize
115:
116: The changelogs are described only in the Japanese version of this document.
1.1 takayama 117:
1.2 takayama 118: @node Functions of HGM for two way contingency tables,,, Top
119: @chapter Functions of HGM for two way contingency tables
120:
121: @comment --- section ``実験的関数'' の subsection xyz_abc
122: @comment --- subsection xyz_pqr xyz_stu がある.
1.1 takayama 123: @menu
1.2 takayama 124: * gtt_ekn3.gmvector::
125: * gtt_ekn3.nc::
126: * gtt_ekn3.lognc::
127: * gtt_ekn3.expectation::
128: * gtt_ekn3.setup::
129: * gtt_ekn3.upAlpha::
1.3 ! takayama 130: * gtt_ekn3.downAlpha::
1.2 takayama 131: * gtt_ekn3.cmle::
132: * gtt_ekn3.set_debug_level::
133: * gtt_ekn3.contiguity_mat_list_2::
134: * gtt_ekn3.show_path::
135: * gtt_ekn3.get_svalue::
136: * gtt_ekn3.assert1::
137: * gtt_ekn3.assert2::
138: * gtt_ekn3.assert3::
139: * gtt_ekn3.prob1::
1.1 takayama 140: @end menu
141:
1.2 takayama 142: @node Hypergeometric function E(k,n),,, Functions of HGM for two way contingency tables
143: @section Hypergeometric function E(k,n)
144:
145: @comment **********************************************************
146: @comment --- ◯◯◯◯ の説明
147: @comment --- 個々の関数の説明の開始 ---
148: @comment --- section 名を正確に ---
149: @node gtt_ekn3.gmvector,,, hypergeometric function E(k,n)
150: @subsection @code{gtt_ekn3.gmvector}
151: @comment --- 索引用キーワード
152: @findex gtt_ekn3.gmvector
153:
154: @table @t
155: @item gtt_ekn3.gmvector(@var{beta},@var{p})
156: :: It returns the value of the hypergeometric function E(k,n) and its derivatives associated to the two way contingency table with the marginal sum @var{beta}, parameter @var{p} (cell probability).
157: @item
158: It is an alias of gtt_ekn3.ekn_cBasis_2(@var{beta},@var{p})
159: @end table
160:
161: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
162: @table @var
163: @item return
164: vector, see below.
165: @item beta
166: a list of the row sum and the colum sum.
167: @item p
168: the parameter.
169: @end table
170:
171: @comment --- ここで関数の詳しい説明 ---
172: @comment --- @itemize〜@end itemize は箇条書き ---
173: @comment --- @bullet は黒点付き ---
174: @itemize @bullet
175: @item
176: The name gmvector is an abreviation of the Gauss-Manin vector defined in [GM2016].
177: @item
178: The return value is the vector S in the page 23 (the section 6) of
179: [GM2016].
180: This is a constant multiple of the vector F in the section 4 of [GM2016]
181: and the constant is determined so that the first element of the vector
182: is equal to the value of the series S in the section 6 of [GM2016].
183: @item
184: Consider an r1 x r2 contingency table.
185: Put m+1=r1, n+1=r2.
186: The normalizing constant Z is the sum of p^u/u!
187: where u is an (m+1) x (n+1) matrix (contingency table) with non-negative integer entries.
188: The sum is taken over u such that the row sum and the column sum of u
189: are equal to @var{beta}, see [TKT2015], [GM2016], [TGKT].
190: The first element of S (polynomial in this case) is equal to this polynomial Z
191: with a normalized p =
192: @verbatim
193: [[1,y11,...,y1n],
194: [1,y21,...,y2n],...,
195: [1,ym1, ...,ymn],
196: [1,1, ..., 1]]
197: @end verbatim
198: @comment ekn/Talks/2015-12-3-goto.tex
199: @item
200: The following options are also accepted by several functions, e.g., gmvector, expectation, nc.
201: @item
202: A distributed computation is turned on by the
203: option crt=1 (crt = Chinese remainder theorem)
204: [T2016].
205: The default is crt=0.
206: Parameters for the distributed computation are set by
207: gtt_ekn3.setup.
208: @item
209: Option bs=1. The matrix factorial, which is a product of contiguity relation matrices
210: with different parameters, is evaluated by the binary splitting method.
211: Examples: gtt_ekn3.assert2(15|bs=1)) (3x3 matrix), gtt_ekn3.test5x5(20|bs=1))(5x5 matrix).
212: The default is bs=0.
213: @item
214: Option path. A choice of algorithms to apply contiguity relations.
215: path=2 (the algorithm given in [GM2016]). path=3 (the algorithm given in [TGKT]
216: (revised version)).
217: The default is path=3.
218: @item
219: Option interval. The period of the intermediate reduction of numerators
220: and denominators.
221: A relevant value of ``interval'' will lead to an efficient evaluation,
222: but no optimal value of it is known. See [TGKT] as to details.
223: The default is no intermediate reduction.
224: @item
225: Option x=1. It opens a window for each process.
226: @end itemize
227:
228: @comment --- @example〜@end example は実行例の表示 ---
229: Example: A 2 x 2 contingency table. The row sum is [5,1] and column sum is [3,3].
230: The parameter (cell probability) is
231: [[1/2,1/3],[1/7,1/5]].
232: @example
233: [3000] import("gtt_ekn3.rr");
234: [3001] gtt_ekn3.gmvector([[5,1],[3,3]],[[1/2,1/3],[1/7,1/5]])
235: [775/27783]
236: [200/9261]
237: @end example
238:
1.1 takayama 239:
1.2 takayama 240: Example: Interval option.
241: @example
242: [4009] P=gtt_ekn3.prob1(5,5,100);
243: [[[100,200,300,400,500],[100,200,300,400,500]],
244: [[1,1/2,1/3,1/5,1/7],[1,1/11,1/13,1/17,1/19],
245: [1,1/23,1/29,1/31,1/37],[1,1/41,1/43,1/47,1/53],[1,1,1,1,1]]]
1.1 takayama 246:
1.2 takayama 247: [4010] util_timing(quote(gtt_ekn3.gmvector(P[0],P[1])[1];
248: [cpu,72.852,gc,0,memory,4462742364,real,72.856]
1.1 takayama 249:
1.2 takayama 250: [4011] util_timing(quote(gtt_ekn3.gmvector(P[0],P[1]|interval=100)))[1];
251: [cpu,67.484,gc,0,memory,3535280544,real,67.4844]
252: @end example
1.1 takayama 253:
254:
1.2 takayama 255: @comment --- 参照(リンク)を書く ---
256: @table @t
257: @item Refer to
258: @ref{gtt_ekn3.setup}
259: @ref{gtt_ekn3.pfaffian_basis}
260: @end table
1.1 takayama 261:
262:
1.2 takayama 263: @comment **********************************************************
264: @node gtt_ekn3.nc,,, hypergeometric function E(k,n)
265: @subsection @code{gtt_ekn3.nc}
266: @comment --- 索引用キーワード
267: @findex gtt_ekn3.nc
1.1 takayama 268:
269: @table @t
1.2 takayama 270: @item gtt_ekn3.nc(@var{beta},@var{p})
271: :: It returns the normalizing constant Z and its derivatives for the two way contingency tables
272: with the marginal sum @var{beta} and the parameter (cell probability) @var{p}.
273: See, e.g., [TKT2015], [TGKT] as to the definition of $Z$.
1.1 takayama 274: @end table
275:
1.2 takayama 276: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
1.1 takayama 277: @table @var
278: @item return
1.2 takayama 279: A list [Z,[[d_11 Z, d_12 Z, ...], ..., [d_m1 Z, d_m2 Z, ...., d_mn Z]]]
280: where d_ij Z denotes the partial derivative of Z with respect to the parameter
281: p_ij.
282: @item beta
283: The row sum and the column sum.
284: @item p
285: The parameter (cell probability).
1.1 takayama 286: @end table
287:
1.2 takayama 288: @comment --- ここで関数の詳しい説明 ---
289: @comment --- @itemize〜@end itemize は箇条書き ---
290: @comment --- @bullet は黒点付き ---
1.1 takayama 291: @itemize @bullet
1.2 takayama 292: @item
293: The function nc obtains Z from the value of gmvector by Prop 7.1 of [GM2016].
294: @item
295: See options for gmvector.
1.1 takayama 296: @end itemize
297:
1.2 takayama 298: @comment --- @example〜@end example は実行例の表示 ---
299: Example: A 2x3 contingency table.
1.1 takayama 300: @example
1.2 takayama 301: [2237] gtt_ekn3.nc([[4,5],[2,4,3]],[[1,1/2,1/3],[1,1,1]]);
1.1 takayama 302: [4483/124416,[ 353/7776 1961/15552 185/1728 ]
303: [ 553/20736 1261/15552 1001/13824 ]]
304: @end example
305:
306:
1.2 takayama 307: @comment --- 参照(リンク)を書く ---
308: @table @t
309: @item Refer to
310: @ref{gtt_ekn3.setup}
311: @ref{gtt_ekn3.lognc}
312: @end table
313:
314:
315:
316: @comment **********************************************************
317: @node gtt_ekn3.lognc,,, hypergeometric function E(k,n)
318: @subsection @code{gtt_ekn3.lognc}
319: @comment --- 索引用キーワード
320: @findex gtt_ekn3.lognc
321:
322: @table @t
323: @item gtt_ekn3.lognc(@var{beta},@var{p})
324: :: It returns the logarithm of Z.
325: @end table
326:
327: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
328: @table @var
329: @item return
330: A list [log(Z), [[d_11 log(Z), d_12 log(Z), ...], [d_21 log(Z),...], ... ]
331: @end table
332:
333: @comment --- ここで関数の詳しい説明 ---
334: @comment --- @itemize〜@end itemize は箇条書き ---
335: @comment --- @bullet は黒点付き ---
336: @itemize @bullet
337: @item
338: This function is used to solve the conditional maximal likelihood estimation [TKT2015].
339: @item
340: See options of gmvector.
341: @end itemize
1.1 takayama 342:
1.2 takayama 343: @comment --- @example〜@end example は実行例の表示 ---
344: Example: A 2x3 contingency table. The first element is an approximate value of log(Z).
345: The rests are exact values when the arguments of lognc are rational numbers.
346: @example
347: [2238] gtt_ekn3.lognc([[4,5],[2,4,3]],[[1,1/2,1/3],[1,1,1]]);
348: [-3.32333832422461674630,[ 5648/4483 15688/4483 13320/4483 ]
349: [ 3318/4483 10088/4483 9009/4483 ]]
350: @end example
351:
352: @comment --- 参照(リンク)を書く ---
353: @table @t
354: @item Refer to
355: @ref{gtt_ekn3.setup}
356: @ref{gtt_ekn3.nc}
357: @end table
358:
359:
360: @comment **********************************************************
361: @node gtt_ekn3.expectation,,, hypergeometric function E(k,n)
362: @subsection @code{gtt_ekn3.expectation}
363: @comment --- 索引用キーワード
364: @findex gtt_ekn3.expectation
365:
366: @table @t
367: @item gtt_ekn3.expectation(@var{beta},@var{p})
368: :: It returns the expectation of the hypergeometric distribution with the mariginal sum @var{beta} and the parameter @var{p}.
369: @end table
370:
371: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
372: @table @var
373: @item return
374: The expectation of each cell.
375: @end table
376:
377: @comment --- ここで関数の詳しい説明 ---
378: @comment --- @itemize〜@end itemize は箇条書き ---
379: @comment --- @bullet は黒点付き ---
380: @itemize @bullet
381: @item
382: It is an implementation of Algorithm 7.8 of [GM2016]. A faster algorithm in [TGKT]
383: is chosen with the default option path=3.
384: @item
385: By the option ``index'', it returns only the expections standing for the ``index''.
386: For example, index=[[0,0],[1,1]] in the case of a 2 x 2 contingency table,
387: it returns the expectations for the (2,1) and (2.2) elements
388: (0 stands for no evaluation and 1 stands for doing the evaluation).
389: @item
390: See also options of gmvector.
391: @end itemize
392:
393: @comment --- @example〜@end example は実行例の表示 ---
394:
395: Examples of the evaluation of expectations for 2 x 2 and 3 x 3 contingency tables.
396: @example
397: [2235] gtt_ekn3.expectation([[1,4],[2,3]],[[1,1/3],[1,1]]);
398: [ 2/3 1/3 ]
399: [ 4/3 8/3 ]
400: [2236] gtt_ekn3.expectation([[4,5],[2,4,3]],[[1,1/2,1/3],[1,1,1]]);
401: [ 5648/4483 7844/4483 4440/4483 ]
402: [ 3318/4483 10088/4483 9009/4483 ]
403:
404: [2442] gtt_ekn3.expectation([[4,14,9],[11,6,10]],[[1,1/2,1/3],[1,1/5,1/7],[1,1,1]]);
405: [ 207017568232262040/147000422096729819 163140751505489940/147000422096729819
406: 217843368649167296/147000422096729819 ]
407: [ 1185482401011137878/147000422096729819 358095302885438604/147000422096729819
408: 514428205457640984/147000422096729819 ]
409: [ 224504673820628091/147000422096729819 360766478189450370/147000422096729819
410: 737732646860489910/147000422096729819 ]
411: @end example
412:
413:
414: @comment --- 参照(リンク)を書く ---
415: @table @t
416: @item Refer to
417: @ref{gtt_ekn3.setup}
418: @ref{gtt_ekn3.nc}
419: @end table
420:
421:
422: @comment **********************************************************
423: @comment --- ◯◯◯◯ の説明
424: @comment --- 個々の関数の説明の開始 ---
425: @comment --- section 名を正確に ---
426: @node gtt_ekn3.setup,,, hypergeometric function E(k,n)
427: @subsection @code{gtt_ekn3.setup}
428: @comment --- 索引用キーワード
429: @findex gtt_ekn3.setup
430:
431: @table @t
432: @item gtt_ekn3.setup()
433: :: It sets parameters for a distributed computation or report the current values of the parameters.
434: @end table
435:
436: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
437: @table @var
438: @item return
439: 0
440: @end table
441:
442: @comment --- ここで関数の詳しい説明 ---
443: @comment --- @itemize〜@end itemize は箇条書き ---
444: @comment --- @bullet は黒点付き ---
445: @itemize @bullet
446: @item It shows the number of processes, the number of primes, the minimal prime which is used.
447: @item Option nps : the number of processes.
448: @item Option nprm : the number of the primes used. When the argument of this option is a string, a list of primes are supposed to be given in the file by the name given by the string.
449: @item Option minp : the minimal prime. It is used with the option nprm. It generates nprm primes more than or equal to minp. When the option fgp is given, the generated primes are stored in the file of the name fgp.
450: @item The default values of nps, nprm, and fgp are nps=1. nprm=10. fgp=0 (no saving).
451: @item The option report=1 shows the current parameters.
452: @item Option subprogs=[file1,file2,...]. These files are loaded to the child processes. The default value is subprogs=["gtt_ekn3/childprocess.rr"].
453: @item The function gtt_ekn3.set_debug_level(Mode) is used to set a debug message level ( Ekn_debug )
454: @end itemize
455:
456: @comment --- @example〜@end example は実行例の表示 ---
457: Example: Generating a list of primes and outputing them to the file p.txt.
458: @example
459: gtt_ekn3.setup(|nps=2,nprm=20,minp=10^10,fgp="p.txt")$
460: @end example
461:
462: Example: Evaluating the gmvector by the Chinese remainder theorem (crt).
463: @example
464: [2867] gtt_ekn3.setup(|nprm=20,minp=10^20);
465: [2868] N=2; T2=gtt_ekn3.gmvector([[36*N,13*N-1],[38*N-1,11*N]],
466: [[1,(1-1/N)/56],[1,1]] | crt=1)$
467: @end example
468:
469:
470: @comment --- 参照(リンク)を書く ---
471: @table @t
472: @item Refer to
473: @ref{gtt_ekn3.nc}
474: @ref{gtt_ekn3.gmvector}
475: @end table
476:
477:
478: @comment **********************************************************
479: @comment --- ◯◯◯◯ の説明
480: @comment --- 個々の関数の説明の開始 ---
481: @comment --- section 名を正確に ---
482: @node gtt_ekn3.upAlpha,,, hypergeometric function E(k,n)
483: @node gtt_ekn3.downAlpha,,, hypergeometric function E(k,n)
484: @subsection @code{gtt_ekn3.upAlpha}, @code{gtt_ekn3.downAlpha}
485: @comment --- 索引用キーワード
486: @findex gtt_ekn3.upAlpha
487: @findex gtt_ekn3.downAlpha
488:
489: @table @t
490: @item gtt_ekn3.upAlpha(@var{i},@var{k},@var{n})
491: @item gtt_ekn3.downAlpha(@var{i},@var{k},@var{n})
492: ::
493: @end table
494:
495: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
496: @table @var
497: @item i
498: It indicates the direction of the contiguity relation to get. In other words, the contiguity relation from a_i to a_i+1 (from a_i to a_i-1, the downAlpha case) is obtained.
499: @item k, n
500: The contiguity relation for the hypergeometric function E(k+1,n+k+2) standing for the (k+1)×(n+1) contingency table is obtained.
501: @item return
502: The matrix representation of the contiguity relation with respect to the pfaffian_basis
503: (see gtt_ekn3.pfaffian_basis). See also Cor 6.3 of [GM2016].
504: @end table
505:
506: @comment --- ここで関数の詳しい説明 ---
507: @comment --- @itemize〜@end itemize は箇条書き ---
508: @comment --- @bullet は黒点付き ---
509: @itemize @bullet
510: @item
511: The function upAlpha returns the matrix U_i of Cor 6.3 in [GM2016].
512: @item
513: The function downAlpha is for the contiguity relation from a_i to a_i-1 .
514: @item
515: The function marginaltoAlpha([row sum,column sum]) translates the marginal sum to values of a_i's.
516: @item
517: The function pfaffian_basis returns F in section 4 of [GM2016]. See the example below.
518: @item
519: The variables a_i and x_i_j can be specialized to numbers by the optional arguments arule and xrule. See the example below.
520: @end itemize
521:
522: @comment --- @example〜@end example は実行例の表示 ---
523: Example: 2x2 contingency table (E(2,4)), 2x3 contingency table (E(2,5)).
524: Outputs of [2221] --- [2225] are left out.
525: @example
526: [2221] gtt_ekn3.marginaltoAlpha([[1,4],[2,3]]);
527: [[a_0,-4],[a_1,-1],[a_2,3],[a_3,2]]
528: [2222] gtt_ekn3.upAlpha(1,1,1); // contiguity relation of E(2,4)
529: // for the a_1 direction
530: [2223] gtt_ekn3.upAlpha(2,1,1); // E(2,4), a_2 direction
531: [2224] gtt_ekn3.upAlpha(3,1,1); // E(2,4), a_3 direction
532: [2225] function f(x_1_1);
533: [2232] gtt_ekn3.pfaffian_basis(f(x_1_1),1,1);
534: [ f(x_1_1) ]
535: [ (f{1}(x_1_1)*x_1_1)/(a_2) ]
536: [2233] function f(x_1_1,x_1_2);
537: f() redefined.
538: [2234] gtt_ekn3.pfaffian_basis(f(x_1_1,x_1_2),1,2); // E(2,5), 2*3 contingency table
539: [ f(x_1_1,x_1_2) ]
540: [ (f{1,0}(x_1_1,x_1_2)*x_1_1)/(a_2) ]
541: [ (f{0,1}(x_1_1,x_1_2)*x_1_2)/(a_3) ]
542:
543: [2235] RuleA=[[a_2,1/3],[a_3,1/2]]$ RuleX=[[x_1_1,1/5]]$
544: base_replace(gtt_ekn3.upAlpha(1,1,1),append(RuleA,RuleX))
545: -gtt_ekn3.upAlpha(1,1,1 | arule=RuleA, xrule=RuleX);
546:
547: [ 0 0 ]
548: [ 0 0 ]
549:
550: @end example
551:
552:
553: @comment --- 参照(リンク)を書く ---
554: @table @t
555: @item Refer to
556: @ref{gtt_ekn3.nc}
557: @ref{gtt_ekn3.gmvector}
558: @end table
559:
560:
561:
562: @comment **********************************************************
563: @comment --- ◯◯◯◯ の説明
564: @comment --- 個々の関数の説明の開始 ---
565: @comment --- section 名を正確に ---
566: @node gtt_ekn3.cmle,,, hypergeometric function E(k,n)
567: @subsection @code{gtt_ekn3.cmle}
568: @comment --- 索引用キーワード
569: @findex gtt_ekn3.cmle
570:
571: @table @t
572: @item gtt_ekn3.cmle(@var{u})
573: :: It finds a parameter p (cell probability) which maximizes P(U=u | row sum, column sum = these of U) for given observed data u. The value of p is an approximate value.
574: @end table
575:
576: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
577: @table @var
578: @item u
579: The observed data.
580: @item return
581: An estimated parameter p
582: @end table
583:
584: @comment --- ここで関数の詳しい説明 ---
585: @comment --- @itemize〜@end itemize は箇条書き ---
586: @comment --- @bullet は黒点付き ---
587: @itemize @bullet
588: @item Todo,
589: optional parameter to set the step size of the gradient descent.
590: @end itemize
591:
592: @comment --- @example〜@end example は実行例の表示 ---
593: Example: 2x4 contingency table.
594: @example
595: U=[[1,1,2,3],[1,3,1,1]];
596: gtt_ekn3.cmle(U);
597: [[ 1 1 2 3 ]
598: [ 1 3 1 1 ],[[7,6],[2,4,3,4]], // Data, row sum, column sum
599: [ 1 67147/183792 120403/64148 48801/17869 ] // p obtained.
600: [ 1 1 1 1 ]]
601: @end example
602:
603:
604: @comment --- 参照(リンク)を書く ---
605: @table @t
606: @item Refer to
607: @ref{gtt_ekn3.expectation}
608: @end table
609:
610:
611: @comment **********************************************************
612: @comment --- ◯◯◯◯ の説明
613: @comment --- 個々の関数の説明の開始 ---
614: @comment --- section 名を正確に ---
615: @node gtt_ekn3.set_debug_level,,, hypergeometric function E(k,n)
616: @node gtt_ekn3.contiguity_mat_list_2,,, hypergeometric function E(k,n)
617: @node gtt_ekn3.show_path,,, hypergeometric function E(k,n)
618: @node gtt_ekn3.get_svalue,,, hypergeometric function E(k,n)
619: @node gtt_ekn3.assert1,,, hypergeometric function E(k,n)
620: @node gtt_ekn3.assert2,,, hypergeometric function E(k,n)
621: @node gtt_ekn3.assert3,,, hypergeometric function E(k,n)
622: @node gtt_ekn3.prob1,,, hypergeometric function E(k,n)
623: @subsection @code{gtt_ekn3.set_debug_level}, @code{gtt_ekn3.show_path}, @code{gtt_ekn3.get_svalue}, @code{gtt_ekn3.assert1}, @code{gtt_ekn3.assert2}, @code{gtt_ekn3.assert3}, @code{gtt_ekn3.prob1}
624: @comment --- 索引用キーワード
625: @findex gtt_ekn3.set_debug_level
626: @findex gtt_ekn3.contiguity_mat_list_2
627: @findex gtt_ekn3.show_path
628: @findex gtt_ekn3.get_svalue
629: @findex gtt_ekn3.assert1
630: @findex gtt_ekn3.assert2
631: @findex gtt_ekn3.assert3
632: @findex gtt_ekn3.prob1
633:
634: @table @t
635: @item gtt_ekn3.set_debug_level(@var{m})
636: :: It sets the level of debug messages.
637: @item gtt_ekn3.contiguity_mat_list_2
638: :: It returns a list of contiguity directions to be used.
639: @item gtt_ekn3.show_path()
640: :: It returns the path to apply contiguity relations. See [TGKT].
641: @item gtt_ekn3.get_svalue()
642: :: It returns the values of the static variables.
643: @item gtt_ekn3.assert1(@var{N})
644: :: It checks the system by 2x2 contingency tables. @var{N} is proportional to the marginal sum.
645: @item gtt_ekn3.assert2(@var{N})
646: :: It checks the system by 3x3 contingency tables.
647: @item gtt_ekn3.assert3(@var{R1}, @var{R2}, @var{Size})
648: :: It checks the distributed computation system by R1 x R2 contingency tables.
649: @item gtt_ekn3.prob1(@var{R1},@var{R2},@var{Size})
650: :: It returns a test data for R1 x R2 contingency tables in the format
651: [marginal sum, parameter p].
652: The marginal sum is proportional to @var{Size}. See benchmark tests in [TGKT].
653: @end table
654:
655:
656: @comment --- ここで関数の詳しい説明 ---
657: @comment --- @itemize〜@end itemize は箇条書き ---
658: @comment --- @bullet は黒点付き ---
659: @itemize @bullet
660: @item
661: Let @var{m} be the debug level. When (@var{m} & 0x1) == 0x1, the values by g_mat_fac_test_plain and g_mat_fac_itor (distributed method is used) are compated.
662: Note that gtt_ekn3.setup() is properly executed before doing these evaluations.
663: @item
664: When (@var{m} & 0x2) == 0x2, the arguments of g_mat_fac_test are stored in the file tmp-input-[number].ab.
665: @item
666: When (@var{m} & 0x4) == 0x4, the arguments for the matrix factorial computation are printed.
667: @item
668: The function @code{get_svalue} returns the list of the values of @code{[Ekn_plist,Ekn_IDL,Ekn_debug,Ekn_mesg,XRule,ARule,Verbose,Ekn_Rq]}.
669: @item
670: Options of assert3: ``x=1'' shows the window attached to every subprocess.
671: With ``nps=m'', m processes are used to obtain contiguity relations.
672: The options crt, interval, ... of gmvector are also accepted.
673: In order to display the timing data, do load("gtt_ekn3/ekn_eval-timing.rr"); before starting this function.
674: @end itemize
675:
676: @comment --- @example〜@end example は実行例の表示 ---
677: Example:
678: @example
679: [2846] gtt_ekn3.set_debug_level(0x4);
680: [2847] N=2; T2=gtt_ekn3.gmvector([[36*N,13*N-1],[38*N-1,11*N]],
681: [[1,(1-1/N)/56],[1,1]])$
682: [2848]
683: level&0x4: g_mat_fac_test([ 113/112 ]
684: [ 1/112 ],[ (t+225/112)/(t^2+4*t+4) (111/112*t+111/112)/(t^2+4*t+4) ]
685: [ (1/112)/(t^2+4*t+4) (111/112*t+111/112)/(t^2+4*t+4) ],0,20,1,t)
686: Note: we do not use g_mat_fac_itor. Call gtt_ekn3.setup(); to use the crt option.
687: level&0x4: g_mat_fac_test([ 67/62944040755546030080000 ]
688: [ 1/125888081511092060160000 ],[ (t+24)/(t^2+25*t+46) (2442)/(t^2+25*t+46) ]
689: [ (1)/(t^2+25*t+46) (-111*t-111)/(t^2+25*t+46) ],0,73,1,t)
690: level&0x4: g_mat_fac_test ------ snip
691: @end example
692:
1.3 ! takayama 693: Example:
1.2 takayama 694: @example
695: [2659] gtt_ekn3.nc([[4,5,6],[2,4,9]],[[1,1/2,1/3],[1,1/5,1/7],[1,1,1]])$
696: [2660] L=matrix_transpose(gtt_ekn3.show_path())$
697: [2661] L[2];
698: [2 1]
699: @end example
700: This means that the contiguity relations for the directions [2 1] (a_2, a_1) are used to evaluate the normalizing constant Z.
701: L[0] is the contiguity matrix,
702: L[1] is a list of the steps to apply for corresponding relations.
703:
1.3 ! takayama 704: Example: Finding a path without evaluations of gmvectors.
1.2 takayama 705: @example
706: A=gtt_ekn3.marginaltoAlpha_list([[400,410,1011],[910,411,500]])$
707: [2666] gtt_ekn3.contiguity_mat_list_2(A,2,2)$
708: [2667] L=matrix_transpose(gtt_ekn3.show_path())$
709: [2668] L[2];
710: [ 2 1 5 4 3 ]
711: [2669] gtt_ekn3.contiguity_mat_list_3(A,2,2)$ // new alg in [TGKT]
712: [2670] L=matrix_transpose(gtt_ekn3.show_path())$
713: [2671] L[2];
714: [2 1] // shorter
715: @end example
716:
1.3 ! takayama 717: Example: When assert2() returns 0 matrices, then the results of g_mat_fac_plain and g_mat_fac_int
1.2 takayama 718: agree. In other words, the system is OK.
719: @example
720: [8859] gtt_ekn3.assert2(1);
721: Marginal=[[130,170,353],[90,119,444]]
722: P=[[17/100,1,10],[7/50,1,33/10],[1,1,1]]
723: Try g_mat_fac_test_int: Note: we do not use g_mat_fac_itor. Call gtt_ekn3.setup(); to use the crt option.
724: Timing (int) =0.413916 (CPU) + 0.590723 (GC) = 1.00464 (total), real time=0.990672
725:
726: Try g_mat_fac_test_plain: Note: we do not use g_mat_fac_itor. Call gtt_ekn3.setup(); to use the crt option.
727: Timing (rational) =4.51349 (CPU) + 6.32174 (GC) = 10.8352 (total)
728: diff of both method =
729: [ 0 0 0 ]
730: [ 0 0 0 ]
731: [ 0 0 0 ]
732: [8860]
733:
734: [8863] gtt_ekn3.setup(|nprm=100,minp=10^50);
735: Number of processes = 1.
736: Number of primes = 100.
737: Min of plist = 100000000000000000000000000000000000000000000000151.
738: 0
739: [8864] gtt_ekn3.assert2(1 | crt=1);
740: Marginal=[[130,170,353],[90,119,444]]
741: P=[[17/100,1,10],[7/50,1,33/10],[1,1,1]]
742: Try [[crt,1]]
743: ---- snip
744: @end example
745:
1.3 ! takayama 746: Example:
1.2 takayama 747: 3x5 contingency table.
748: The parameter p (cell probability) is a list of 1/(prime number) 's.
749: @example
750: @comment grep testnxn ekn/Prog2/*.rr ; grep test_nxn ekn/Prog2/*.rr も見よ.
751: [9054] L=gtt_ekn3.prob1(3,5,10 | factor=1, factor_row=3);
752: [[[10,20,420],[30,60,90,120,150]],[[1,1/2,1/3,1/5,1/7],[1,1/11,1/13,1/17,1/19],[1,1,1,1,1]]]
753: [9055] number_eval(gtt_ekn3.expectation(L[0],L[1]));
754: [ 1.65224223218613 ... snip ]
755: @end example
756:
1.3 ! takayama 757: Example:
1.2 takayama 758: @example
759: [5779] import("gtt_ekn3.rr"); load("gtt_ekn3/ekn_eval-timing.rr");
760: [5780] gtt_ekn3.assert3(5,5,100 | nps=32, interval=100);
761: -- snip
762: Parallel method: Number of process=32, File name tmp-gtt_ekn3/p300.txt is written.
763: Number of processes = 32.
764: -- snip
765: initialPoly of path=3: [ 2.184 0 124341044 2.1831 ] [CPU(s),0,*,real(s)]
766: contiguity_mat_list_3 of path=3: [ 0.04 0 630644 9.6774 ] [CPU(s),0,*,real(s)]
767: Note: interval option will lead faster evaluation. We do not use g_mat_fac_itor (crt). Call gtt_ekn3.setup(); to use the crt option.
768: g_mat_fac of path=3: [ 21.644 0 1863290168 21.6457 ] [CPU(s),0,*,real(s)]
769: Done. Saved in 2.ab
770: Diff (should be 0)=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,..., 0,0,0]
771: @end example
772:
773: @comment --- 参照(リンク)を書く ---
774: @table @t
775: @item Refer to
776: @ref{gtt_ekn3.nc}
777: @end table
778:
779:
780:
781: @node Modular method,,, Top
782: @chapter Modular method
783:
784: @menu
785: * gtt_ekn3.chinese_itor::
786: @end menu
787:
788: @node Chinese remainder theorem and itor,,, Modular method
789: @section Chinese remainder theorem and itor
790:
791: @comment **********************************************************
792: @comment --- ◯◯◯◯ の説明
793: @comment --- 個々の関数の説明の開始 ---
794: @comment --- section 名を正確に ---
795: @node gtt_ekn3.chinese_itor,,,
796: @subsection @code{gtt_ekn3.chinese_itor}
797: @comment --- 索引用キーワード
798: @findex gtt_ekn3.chinese_itor Chinese remainder theorem and itor
799:
800: @table @t
801: @item gtt_ekn3.chinese_itor(@var{data},@var{idlist})
802: :: It performs a rational reconstruction by the Chinese remainder theorem (itor = integer to rational).
803: @end table
804:
805: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
806: @table @var
807: @item return
808: [val, n], the vector val is the value by the rational reconstruction. n = n1*n2*...
809: @item data
810: [[val1,n1],[val2,n2], ...], val1, val2 are values evaluated in mod n1, mod n2, ... respectively. The relations val mod n1 = val1, val mod n2 = val2,.. are satisfied.
811: @item idlist
812: The list of server id's for itor.
813: @end table
814:
815: @comment --- ここで関数の詳しい説明 ---
816: @comment --- @itemize〜@end itemize は箇条書き ---
817: @comment --- @bullet は黒点付き ---
818: @itemize @bullet
819: @item When it cannot find val, it returns failure.
820: @end itemize
821:
822: @comment --- @example〜@end example は実行例の表示 ---
823: Example: [3!, 5^3*3!]=[6,750] is the return value.
824: The relations 6 mod 109 =6, 750 mod 109=96 stand for [[6,96],109], ...
825: @example
826: gtt_ekn3.setup(|nps=2,nprm=3,minp=101,fgp="p_small.txt");
827: SS=gtt_ekn3.get_svalue();
828: SS[0];
829: [103,107,109] // list of primes
830: SS[1];
831: [0,2] // list of server ID's
832: gtt_ekn3.chinese_itor([[[ 6,96 ],109],[[ 6,29 ],103],[[ 6,1 ],107]],SS[1]);
833: [[ 6 750 ],1201289]
834:
835: // The argument may be a scalar.
836: gtt_ekn3.chinese_itor([[96,109],[29,103]],SS[1]);
837: [[ 750 ],11227]
838: @end example
839:
840:
841:
842:
843: @comment --- 参照(リンク)を書く ---
844: @table @t
845: @item Refer to
846: @ref{gtt_ekn3.setup}
847: @end table
848:
849:
850: @node Binary splitting,,, Top
851: @chapter Binary splitting
852:
853: @menu
854: * gtt_ekn3.init_dm_bsplit::
855: * gtt_ekn3.setup_dm_bsplit::
856: * gtt_ekn3.init_bsplit::
857: @end menu
858:
859: @node Matrix factorial,,, Binary splitting
860: @section Matrix factorial
861:
862: @comment **********************************************************
863: @comment --- ◯◯◯◯ の説明
864: @comment --- 個々の関数の説明の開始 ---
865: @comment --- section 名を正確に ---
866: @node gtt_ekn3.init_bsplit,,,
867: @node gtt_ekn3.init_dm_bsplit,,,
868: @node gtt_ekn3.setup_dm_bsplit,,,
869: @subsection @code{gtt_ekn3.init_bsplit, gtt_ekn3.init_dm_bsplit, gtt_ekn3.setup_dm_bsplit}
870: @comment --- 索引用キーワード
871: @findex gtt_ekn3.init_dm_bsplit matrix factorial
872: @findex gtt_ekn3.setup_dm_bsplit matrix factorial
873: @findex gtt_ekn3.init_bsplit matrix factorial
874:
875: @table @t
876: @item gtt_ekn3.init_bsplit(|minsize=16,levelmax=1);
877: :: It sets parameters for the binary splitting to evaluate the matrix factorial M(1) M(2) ... M(n) where M(k) is a matrix with a parameter k.
878: @item gtt_ekn3.init_dm_bsplit(|bsplit_x=0, bsplit_reduce=0)
879: :: It sets parameters for the binary splitting by a distributed computation.
880: @item gtt_ekn3.setup_dm_bsplit(C)
881: :: It starts C processes for the binary splitting.
882: @end table
883:
884: @comment --- 引数の簡単な説明 --- 以下まだ書いてない.
885: @table @var
886: @item Option minsize.
887: When the size of the matrix factorial is less than the minsize, the binary splitting is not used and sequential multiplication is used instead.
888: @item Option levelmax.
889: The maximum of recursions of the recursive binary splitting in the distributed computation. See gtt_ekn3/dm_bsplit.rr
890: C should be set to levelmax-1. When levalmax=1, the distributed computation is not performed.
891: @item Option bsplit_x.
892: When bsplit_x=1, a window attached to every process is opened.
893: @end table
894:
895:
896: @comment --- @example〜@end example は実行例の表示 ---
897: Example: A comparison of bs=1 and no bs.
898: @example
899: [4618] cputime(1)$
900: [4619] gtt_ekn3.expectation(Marginal=[[1950,2550,5295],[1350,1785,6660]],
901: P=[[17/100,1,10],[7/50,1,33/10],[1,1,1]]|bs=1)$
902: 4.912sec(4.914sec)
903: [4621] V2=gtt_ekn3.expectation(Marginal,P)$
904: 6.752sec(6.756sec)
905: @end example
906:
907:
908: @comment --- @example〜@end example は実行例の表示 ---
909: Example:
910: Note that distributed computations are often slower than computations on a single process
911: in our implementation of the binary splitting.
912: The option bsplit_x=1 opens
913: a debug windows, it makes things slower.
914: The function gtt_ekn3.test_bs_dist() is a test function of the binary splitting by a distributed computation.
915: @example
916: [3669] C=4$ gtt_ekn3.init_bsplit(|minsize=16,levelmax=C+1)$
917: gtt_ekn3.init_dm_bsplit(|bsplit_x=1)$
918: [3670] [3671] [3672] gtt_ekn3.setup_dm_bsplit(C);
919: [0,0]
920: [3673] gtt_ekn3.assert2(10|bs=1)$
921: @end example
922:
923: @comment --- 参照(リンク)を書く ---
924: @table @t
925: @item Refer to
926: @ref{gtt_ekn3.gmvector}
927: @ref{gtt_ekn3.expectation}
928: @ref{gtt_ekn3.assert1}
929: @ref{gtt_ekn3.assert2}
930: @end table
931:
932:
933: @comment --- おまじない ---
1.1 takayama 934: @node Index,,, Top
935: @unnumbered Index
936: @printindex fn
937: @printindex cp
938: @iftex
939: @vfill @eject
940: @end iftex
941: @summarycontents
942: @contents
1.2 takayama 943: @bye
944: @comment --- おまじない終り ---
1.1 takayama 945:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>