⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mf_fft.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
📖 第 1 页 / 共 2 页
字号:

{p 4 4 2}
Everything said about {cmd:convolve()} applies equally to {cmd:deconvolve()}.


{title:Correlation}

{p 4 4 2}
Here we refer to correlation in the signal-processing sense, not the 
statistical sense.

{p 4 4 2}
{cmd:Corr(}{it:g}{cmd:,} {it:h}{cmd:,} {it:k}{cmd:)}
returns a 2{it:k}+1 element vector containing the correlations of {it:g} and
{it:h} for lags and leads as large as {it:k}.  
For instance,
{cmd:Corr(}{it:g}{cmd:,} {it:h}{cmd:,} {cmd:2)} returns a 5-element vector,
the first element of which contains the correlation for lag 2, the second
element lag 1, the third (middle) element the contemporaneous correlation, the
fourth element lead 1, and the fifth element lead 2.  {it:k} must be greater
than or equal to 1.  The returned vector is a row or column vector depending on
whether {it:g} is a row or column vector.  {it:g} and {it:h} must have the same
number of elements, but need not be p-conformable.

{p 4 4 2}
The result is obtained by padding with zeros to avoid contamination, taking
the Fourier transform, multiplying {it:G}*conj({it:H}), and rearranging the
inverse transformed result.  Nevertheless, it is not required that the number
of elements of {it:g} and {it:h} be powers of 2 because the program pads
internally.


{title:Utility routines}

{p 4 4 2}
{cmd:ftpad(}{it:h}{cmd:)} returns {it:h} padded with 0s to have a length
that is a power of 2.  For instance,

	: {cmd:h = (1,2,3,4,5)}

	: {cmd:ftpad(h)}
        {res}       {txt}1   2   3   4   5   6   7   8
            {c TLC}{hline 33}{c TRC}
          1 {c |}  {res}1   2   3   4   5   0   0   0{txt}  {c |}
            {c BLC}{hline 33}{c BRC}

{p 4 4 2}
If {it:h} is a row vector, a row vector is returned.  If {it:h} is a column
vector, a column vector is returned. 

{p 4 4 2}
{cmd:ftwrap(}{it:r}{cmd:,} {it:n}{cmd:)} 
converts the symmetrically stored response function
{it:r} into wraparound format of length {it:n},
{it:n}>=rows({it:r})*cols({it:r}) and rows({it:r})*cols({it:r}) odd.  A
symmetrically stored response function is a vector of odd length, for example:

			(.1, .5, 1, .2, .4)

{p 4 4 2}
The middle element of the vector represents the response function at lag 0.
Elements before the middle represent lags while elements after the
middle represent leads.  In this case, .1 is the response for lag 2 and .5 for
lag 1, 1 the contemporaneous response, .2 the response for lead 1, and .4 the
response for lead 2.  The wraparound format of a response function records the
response at times 0, 1, and so on in the first positions, has some number of
zeros, and then records the most negative time value of the response function,
and so on.

{p 4 4 2}
For instance,

	: {cmd:r}
        {res}       {txt} 1    2    3    4    5
            {c TLC}{hline 26}{c TRC}
          1 {c |}  {res}.1   .5    1   .2   .4{txt}  {c |}
            {c BLC}{hline 26}{c BRC}

	: {cmd:ftwrap(r, 5)}
        {res}       {txt} 1    2    3    4    5
            {c TLC}{hline 26}{c TRC}
          1 {c |}  {res} 1   .2   .4   .1   .5{txt}  {c |}
            {c BLC}{hline 26}{c BRC}

	: {cmd:ftwrap(r, 6)}
        {res}       {txt} 1    2    3    4    5    6
            {c TLC}{hline 31}{c TRC}
          1 {c |}  {res} 1   .2   .4    0   .1   .5{txt}  {c |}
            {c BLC}{hline 31}{c BRC}

	: {cmd:ftwrap(r, 8)}
        {res}       {txt} 1    2    3    4    5    6    7    8
            {c TLC}{hline 41}{c TRC}
          1 {c |}  {res} 1   .2   .4    0    0    0   .1   .5{txt}  {c |}
            {c BLC}{hline 41}{c BRC}


	
{p 4 4 2}
{cmd:ftretime(}{it:r}{cmd:,} {it:s}{cmd:)} 
retimes the signal {it:s} to be on the same time scale as
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)}.  This is useful in graphing and
listing results but is otherwise not required.  {cmd:ftretime()} only uses the
length of {it:r}, and not its contents, to perform the retiming.  If the
response vector is of length 2{it:k}+1, a vector containing {it:k} zeros,
{it:s}, and {it:k} more zeros is returned.  Thus the result of
{cmd:ftretime(}{it:r}{cmd:,} {it:s}{cmd:)} is p-conformable with
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)}.



{p 4 4 2}
{cmd:ftunwrap(}{it:H}{it:)} unwraps frequency-wraparound order such as
returned by {cmd:fft()}.  You may find this useful when graphing or listing
results, but it is otherwise unnecessary.  Frequency-unwrapped order is
defined as


			unwrap[1]       frequency -({it:n}/2) + 1
			unwrap[2]       frequency -({it:n}/2) + 2
			.
			unwrap[{it:n}/2-1]   frequency -1
			unwrap[{it:n}/2]     frequency 0
			unwrap[{it:n}/2+1]   frequency 1
			.
			unwrap[{it:n}-1]     frequency {it:n}/2 - 1
			unwrap[{it:n}]       frequency {it:n}/2

{p 4 4 2}
Here we assume that {it:n} is even, as will be true in most cases.  Note 
the aliased (highest) frequency is assigned the positive sign.

{p 4 4 2}
Also see {cmd:ftperiodogram()}, below.



{p 4 4 2}
{cmd:ftfreqs(}{it:H}{cmd:,} {it:delta}{cmd:)} 
returns a p-conformable-with-{it:H} vector containing the frequencies
associated with the elements of {it:H}.  {it:delta} is the sampling interval
and is often specified as 1.



{p 4 4 2}
{cmd:ftperiodogram(}{it:H}{cmd:)} returns a real vector of length {it:n}/2
containing the one-sided periodogram of {it:H} (length {it:n}),
calculated as

			abs({it:H}({it:f}))^2 + abs({it:H}(-{it:f}))^2

{p 4 4 2}
excluding frequency 0.  Thus {cmd:ftperiodogram(}{it:H}{cmd:)[1]} 
corresponds to frequency 1 (-1), 
{cmd:ftperiodogram(}{it:H}{cmd:)[2]} to frequency 2 (-2), and so
on.  



{title:Warnings}

{p 4 4 2}
{cmd:invfft(}{it:H}{cmd:)} will cast the result down to real if possible.
Code {cmd:C(invfft(}{it:H}{cmd:))} if you want to be assured of the 
result being stored as complex.

{p 4 4 2}
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)} is not the same as 
{cmd:convolve(}{it:s}{cmd:,} {it:r}{cmd:)}.

{p 4 4 2}
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)} 
will cast the result down to real if possible.
Code {cmd:C(convolve(}{it:r}{cmd:,} {it:s}{cmd:))} 
if you want to be assured of the result being stored as complex.

{p 4 4 2}
For 
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)}, 
the response function {it:r} must have odd length.


{title:Conformability}

    {cmd:fft(}{it:h}{cmd:)}:
		{it:h}:  1 {it:x n}  or  {it:n x} 1,  {it:n} a power of 2
	   {it:result}:  1 {it:x n}  or  {it:n x} 1

    {cmd:_fft(}{it:h}{cmd:)}:
		{it:h}:  1 {it:x n}  or  {it:n x} 1,  {it:n} a power of 2
	   {it:result}:  {it:void}

    {cmd:invfft(}{it:H}{cmd:)}:
		{it:H}:  1 {it:x n}  or  {it:n x} 1,  {it:n} a power of 2
	   {it:result}:  1 {it:x n}  or  {it:n x} 1

    {cmd:_invfft(}{it:H}{cmd:)}:
		{it:h}:  1 {it:x n}  or  {it:n x} 1,  {it:n} a power of 2
	   {it:result}:  {it:void}

{p 4 4 2}
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)}:
{p_end}
		{it:r}:  1 {it:x} {it:n}      or      {it:n} {it:x} 1,  {it:n}>0, {it:n} odd
		{it:s}:  1 {it:x} 2{it:k}+1   or   2{it:k}+1 {it:x} 1,  i.e., {it:s} of odd length
	   {it:result}:  1 {it:x} 2{it:k}+{it:n}   or   2{it:k}+{it:n} {it:x} 1

    {cmd:deconvolve(}{it:r}{cmd:,} {it:sm}{cmd:)}
		{it:r}:  1 {it:x} {it:n}      or      {it:n} {it:x} 1,  {it:n}>0, {it:n} odd
	       {it:sm}:  1 {it:x} 2{it:k}+{it:n}   or   2{it:k}+{it:n} {it:x} 1
	   {it:result}:  1 {it:x} 2{it:k}+1   or   2{it:k}+1 {it:x} 1

{p 4 4 2}
{cmd:Corr(}{it:g}{cmd:,} {it:h}{cmd:,} {it:k}{cmd:)}:
{p_end}
		{it:g}:  1 {it:x} {it:n}      or      {it:n} {it:x} 1,  {it:n}>0
		{it:h}:  1 {it:x} {it:n}      or      {it:n} {it:x} 1
		{it:k}:  1 {it:x} 1      or      1 {it:x} 1,  {it:k}>0
	   {it:result}:  1 {it:x} 2{it:k}+1   or   2{it:k}+1 {it:x} 1

    {cmd:ftpad(}{it:h}{cmd:)}:
		{it:h}:  1 {it:x n}      or      {it:n x} 1
	   {it:result}:  1 {it:x N}      or      {it:N x} 1, {it:N} = {it:n} rounded up to power of 2

    {cmd:ftperiodogram(}{it:H}{cmd:)}:
		{it:H}:  1 {it:x} {it:n}      or     {it:n} {it:x} 1,  {it:n} even
	   {it:result}:	 {it:n}/2 {it:x} 1    or     1 {it:x} {it:n}/2

    {cmd:ftwrap(}{it:r}{cmd:,} {it:n}{cmd:)}:
		{it:r}:  1 {it:x} {it:m}      or      {it:m} {it:x} 1,  {it:m}>0, {it:m} odd
		{it:n}:  1 {it:x} 1      or      1 {it:x} 1,  {it:n} >= {it:m}
	   {it:result}:  1 {it:x} {it:n}      or      {it:n} {it:x} 1

    {cmd:ftretime(}{it:r}{cmd:,} {it:s}{cmd:)}:
		{it:r}:  1 {it:x} {it:n}      or      {it:n} {it:x} 1,  {it:n}>0, {it:n} odd
		{it:s}:  1 {it:x} 2{it:k}+1   or   2{it:k}+1 {it:x} 1,  i.e., {it:s} of odd length
	   {it:result}:  1 {it:x} 2{it:k}+{it:n}   or   2{it:k}+{it:n} {it:x} 1


    {cmd:ftunwrap(}{it:H}{it:)}:
		{it:H}:  1 {it:x} {it:n}      or     {it:n} {it:x} 1
	   {it:result}:	 1 {it:x} {it:n}      or     {it:n} {it:x} 1

    {cmd:ftfreqs(}{it:H}{cmd:,} {it:delta}{cmd:)}:
		{it:H}:  1 {it:x} {it:n}      or     {it:n} {it:x} 1,  {it:n} even
	   {it:result}:	 1 {it:x} {it:n}      or     {it:n} {it:x} 1


{title:Diagnostics}

{p 4 4 2}
All functions abort with error if the conformability requirements are 
not met.  This is always true, of course, but pay particular attention 
to the requirements outlined under {bf:Conformability} directly above.

{p 4 4 2}
{cmd:fft(}{it:h}{cmd:)}, 
{cmd:_fft(}{it:h}{cmd:)},
{cmd:invfft(}{it:H}{cmd:)},
{cmd:_invfft(}{it:H}{cmd:)},
{cmd:convolve(}{it:r}{cmd:,} {it:s}{cmd:)},
{cmd:deconvolve(}{it:r}{cmd:,} {it:sm}{cmd:)}, 
and
{cmd:Corr(}{it:g}{cmd:,} {it:h}{cmd:,} {it:k}{cmd:)}
return missing results if any argument contains missing values.

{p 4 4 2}
{cmd:ftwrap(}{it:r}{cmd:,} {it:n}{cmd:)}
aborts with error if {it:n} contains missing value.


{title:Source code}

{p 4 4 2}
{view fft.mata, adopath asis:fft.mata},
{view invfft.mata, adopath asis:invfft.mata},
{view convolve.mata, adopath asis:convolve.mata},
{view deconvolve.mata, adopath asis:deconvolve.mata},
{view corruppercase.mata, adopath asis:corruppercase.mata},
{view ftperiodogram.mata, adopath asis:ftperiodogram.mata},
{view ftpad.mata, adopath asis:ftpad.mata},
{view ftwrap.mata, adopath asis:ftwrap.mata},
{view ftretime.mata, adopath asis:ftretime.mata},
{view ftunwrap.mata, adopath asis:ftunwrap.mata},
{view ftfreqs.mata, adopath asis:ftfreqs.mata};
{cmd:fft()} and {cmd:_invfft()} are built-in.


{title:Also see}

{p 4 13 2}
Manual:  {hi:[M-5] fft()}

{p 4 13 2}
Online:  help for 
{bf:{help m4_mathematical:[M-4] mathematical}}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -