[doc] misc. patchs & small improvements
[scilab.git] / scilab / modules / signal_processing / help / ja_JP / correlation_convolution / corr.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
3           xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
4           xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
5           xml:lang="ja" xml:id="corr">
6     <refnamediv>
7         <refname>corr</refname>
8         <refpurpose>相関 , 共分散</refpurpose>
9     </refnamediv>
10     <refsynopsisdiv>
11         <title>呼び出し手順</title>
12         <synopsis>
13             [cov,Mean] = corr(x,[y],nlags)
14             [cov,Mean] = corr('fft',xmacro,[ymacro],n,sect)
15             [w,xu] = corr('updt',x1,[y1],w0)
16             [w,xu] = corr('updt',x2,[y2],w,xu)
17             ...
18             wk = corr('updt',xk,[yk],w,xu)
19         </synopsis>
20     </refsynopsisdiv>
21     <refsection>
22         <title>引数</title>
23         <variablelist>
24             <varlistentry>
25                 <term>x</term>
26                 <listitem>
27                     <para>実数ベクトル</para>
28                 </listitem>
29             </varlistentry>
30             <varlistentry>
31                 <term>y</term>
32                 <listitem>
33                     <para>実数ベクトル, デフォルト値 x.</para>
34                 </listitem>
35             </varlistentry>
36             <varlistentry>
37                 <term>nlags</term>
38                 <listitem>
39                     <para>i整数, 指定した相関係数の数.</para>
40                 </listitem>
41             </varlistentry>
42             <varlistentry>
43                 <term>xmacro</term>
44                 <listitem>
45                     <para>scilab 外部ルーチン (下記参照).</para>
46                 </listitem>
47             </varlistentry>
48             <varlistentry>
49                 <term>ymacro</term>
50                 <listitem>
51                     <para>scilab 外部ルーチン (下記参照), デフォルト値: xmacro</para>
52                 </listitem>
53             </varlistentry>
54             <varlistentry>
55                 <term>n</term>
56                 <listitem>
57                     <para>整数, シーケンス全体の大きさ (下記参照).</para>
58                 </listitem>
59             </varlistentry>
60             <varlistentry>
61                 <term>sect</term>
62                 <listitem>
63                     <para>シーケンスのセクションの大きさ (下記参照).</para>
64                 </listitem>
65             </varlistentry>
66             <varlistentry>
67                 <term>xi</term>
68                 <listitem>
69                     <para>実数ベクトル</para>
70                 </listitem>
71             </varlistentry>
72             <varlistentry>
73                 <term>yi</term>
74                 <listitem>
75                     <para>実数ベクトル,デフォルト値: xi.</para>
76                 </listitem>
77             </varlistentry>
78             <varlistentry>
79                 <term>cov</term>
80                 <listitem>
81                     <para>実数ベクトル, 相関係数</para>
82                 </listitem>
83             </varlistentry>
84             <varlistentry>
85                 <term>Mean</term>
86                 <listitem>
87                     <para>実数または実数ベクトル,  x (および y)の平均</para>
88                 </listitem>
89             </varlistentry>
90         </variablelist>
91     </refsection>
92     <refsection>
93         <title>説明</title>
94         <para>
95             <literal>corr(x,y,…)</literal> computes
96             <latex alt="cov(m)=sum_{k=1}^{n-m} (x(k)-mean(x))(y(m+k)-mean(y)) / n">
97             cov(m)=\sum_{k=1}^{n-m} \left(x(k)-mean(x)\right)\left(y(m+k)-mean(y)\right) / n
98             </latex>
99             for <literal>m = 0, …, nlag-1</literal>.
100         </para>
101         <para>
102             シーケンス x および y が異なる場合, corr(x,y,...)はcorr(y,x,...)
103             と異なることに注意してください.
104         </para>
105         <variablelist>
106             <varlistentry>
107                 <term>短いシーケンス</term>
108                 <listitem>
109                     <para>
110                         <literal>[cov,Mean]=corr(x,[y],nlags)</literal> は,
111                         最初の nlags 個の相関係数および Mean = <literal>mean(x)</literal>
112                         (<literal>y</literal> が引数として指定された場合,<literal>[x,y]</literal> の平均)
113                         を返します.
114                         シーケンス  <literal>x</literal> (または <literal>y</literal>) は実数,
115                         <literal>x</literal>と<literal>y</literal>は同じ次元 n と仮定されます.
116                     </para>
117                 </listitem>
118             </varlistentry>
119             <varlistentry>
120                 <term>長いシーケンス</term>
121                 <listitem>
122                     <para>
123                         <literal>[cov,Mean]=corr('fft',xmacro,[ymacro],n,sect)</literal>
124                         ここで,<literal>xmacro</literal> は以下のどちらかです
125                     </para>
126                     <itemizedlist>
127                         <listitem>
128                             <para>
129                                 <literal>[xx]=xmacro(sect,istart)</literal> という型の関数で,
130                                 <literal>istart</literal> から
131                                 <literal>istart+sect-1</literal>までの添字を有するシーケンスの
132                                 一部を含む
133                                 <literal>nsect</literal>次のベクトル<literal>xx</literal>を返します.
134                             </para>
135                         </listitem>
136                         <listitem>
137                             <para>
138                                 FortranサブルーチンまたはCプロシージャで,
139                                 同じ計算を行ないます(例えば,<literal>dgetx</literal>の
140                                 ソースコードを参照ください).
141                             </para>
142                         </listitem>
143                     </itemizedlist>
144                   <para>
145                         <literal>n</literal> = シーケンスの総数.
146                         <literal>sect</literal> = シーケンスのセクションの大きさ.
147                         <literal>sect</literal> は 2の累乗とする必要があります.
148                         <literal>cov</literal> は
149                         <literal>sect</literal>次です.
150                         計算は FFT により行われます.
151                   </para>
152                 </listitem>
153             </varlistentry>
154             <varlistentry>
155                 <term>更新法</term>
156                 <listitem>
157                     <programlisting role=""><![CDATA[
158 [w,xu]=corr('updt',x1,[y1],w0)
159 [w,xu]=corr('updt',x2,[y2],w,xu)
160  ...
161 wk=corr('updt',xk,[yk],w,xu)
162  ]]></programlisting>
163                     <para>
164                         この呼び出し手順では,計算結果が<literal>corr</literal>をコールする度に
165                         更新されます.
166                     </para>
167                     <programlisting role=""><![CDATA[
168 w0 = 0*ones(1,2*nlags);
169 nlags = power of 2.
170  ]]></programlisting>
171                     <para>
172                         <literal>x1,x2,...</literal> は,
173                         <literal>x=[x1,x2,...]</literal>で,<literal>xi</literal>の大きさが
174                         2の累乗となるような<literal>x</literal> の一部です.
175                         <literal>nlags</literal>個の係数を得るには,
176                         最後の fft を <literal>c=fft(w,1)/n</literal>;
177                         <literal>cov=c(1nlags)</literal>を実行する必要があります
178                         (<literal>n</literal> は <literal>x (y)</literal>の大きさ).
179                         注意:
180                         この呼び出し手順は <literal>xmean = ymean = 0</literal> を仮定します.
181                     </para>
182                 </listitem>
183             </varlistentry>
184         </variablelist>
185     </refsection>
186     <refsection>
187         <title>例</title>
188         <programlisting role="example"><![CDATA[
189 x=%pi/10:%pi/10:102.4*%pi;
190 rand('seed');rand('normal');
191 y=[.8*sin(x)+.8*sin(2*x)+rand(x);.8*sin(x)+.8*sin(1.99*x)+rand(x)];
192 c=[];
193 for j=1:2,for k=1:2,c=[c;corr(y(k,:),y(j,:),64)];end;end;
194 c=matrix(c,2,128);cov=[];
195 for j=1:64,cov=[cov;c(:,(j-1)*2+1:2*j)];end;
196
197 rand('normal');
198 x=rand(1,256);y=-x;
199 deff('[z]=xx(inc,is)','z=x(is:is+inc-1)');
200 deff('[z]=yy(inc,is)','z=y(is:is+inc-1)');
201 [c,mxy]=corr(x,y,32);
202 x=x-mxy(1)*ones(x); y=y-mxy(2)*ones(y);  //centering
203 c1=corr(x,y,32);c2=corr(x,32);
204 norm(c1+c2,1)
205 [c3,m3]=corr('fft',xx,yy,256,32);
206 norm(c1-c3,1)
207 [c4,m4]=corr('fft',xx,256,32);
208 norm(m3,1),norm(m4,1)
209 norm(c3-c1,1),norm(c4-c2,1)
210 x1=x(1:128); x2=x(129:256);
211 y1=y(1:128); y2=y(129:256);
212 w0=0*ones(1:64);   //32 coeffs
213 [w1,xu]=corr('u',x1,y1,w0);
214 w2=corr('u',x2,y2,w1,xu);
215 zz=real(fft(w2,1))/256;c5=zz(1:32);
216 norm(c5-c1,1)
217 [w1,xu]=corr('u',x1,w0);
218 w2=corr('u',x2,w1,xu);
219 zz=real(fft(w2,1))/256;c6=zz(1:32);
220 norm(c6-c2,1)
221 rand('unif')
222
223 // Fortran または C 外部ルーチンのテスト
224 //
225 deff('[y]=xmacro(sec,ist)','y=sin(ist:(ist+sec-1))');
226 x=xmacro(100,1);
227 [cc1,mm1]=corr(x,2^3);
228 [cc,mm]=corr('fft',xmacro,100,2^3);
229 [cc2,mm2]=corr('fft','corexx',100,2^3);
230 [max(abs(cc-cc1)), max(abs(mm-mm1)), max(abs(cc-cc2)), max(abs(mm-mm2))]
231
232 deff('[y]=ymacro(sec,ist)','y=cos(ist:(ist+sec-1))');
233 y=ymacro(100,1);
234 [cc1,mm1]=corr(x,y,2^3);
235 [cc,mm]=corr('fft',xmacro,ymacro,100,2^3);
236 [cc2,mm2]=corr('fft','corexx','corexy',100,2^3);
237 [max(abs(cc-cc1)), max(abs(mm-mm1)), max(abs(cc-cc2)), max(abs(mm-mm2))]
238  ]]></programlisting>
239     </refsection>
240     <refsection role="see also">
241         <title>参照</title>
242         <simplelist type="inline">
243             <member>
244                 <link linkend="xcorr">xcorr</link>
245             </member>
246             <member>
247                 <link linkend="xcov">xcov</link>
248             </member>
249             <member>
250                 <link linkend="correl">correl</link>
251             </member>
252             <member>
253                 <link linkend="cov">cov</link>
254             </member>
255             <member>
256                 <link linkend="covar">covar</link>
257             </member>
258         </simplelist>
259     </refsection>
260 </refentry>