Shifting and Scaling

Needs["StableM`"];
SetOptions[FourierTransform,FourierParameters-> {1,1}];
SetOptions[InverseFourierTransform,FourierParameters-> {1,1}];
SetOptions[Fourier, FourierParameters -> {-1,1}];
SetOptions[InverseFourier, FourierParameters -> {-1,1}];
ReOrder::usage = "ReOrder[list] reorders a frequency domain list for the time domain and vice versa.  If Length[list] is odd the output list will be truncated to the next smallest integer.";
XTable::usage="XTable[SR, N] puts out a list of x values that correspond to the stable x-axis in the time domain for a given length, N, and SR of the DFFT list.";
DFTCF::usage= "DFTCF[cf,SR,N] puts out a discrete FT of a distribution specified by the characteric function cf in the frequency domain compatible with FourierParameters -> {-1, 1}.  SR is the sampling rate; SR is greater than 0.  N is the number of points and must be even.  The output is scaled ready for inversion.";
CF1c::usage= "CF1c[u, α, β, γ, δ] outputs a compiled version of the S(α, β, γ, δ; 1) characteristic function.  All the inputs must be real numbers.";
ReOrder=With[{n=Length[#]},Join[Drop[#,Floor[n/2]],Drop[#,-Floor[n/2]]]]&;
XTable  = Compile[{SR, {N,_Integer}},Module[{n},
n=2 Floor[N/2];
Range[-n/2,n/2-1,1]/(SR)]];
DFTCF [cf_,SR_,n_Integer]:=Module[{rlist,n2},
n2=Floor[n/2];
rlist=2. Pi SR/n Join[Range[0,n2-1],Range[-n2,-1]];
Map[cf[ #]&,rlist]SR/n
	];
CF1c=Compile[{#1,#2,#3,#4,#5},If[#1==0,1,If[#2==1,E^(I*#5*#1-#4*Abs[#1]*((2*I*#3*Log[Abs[#1]]*Sign[#1])/Pi+1)),E^(I*#1*#5-Abs[#1]^#2*#4^#2*(1-I*Sign[#1]*#3*Tan[(Pi*#2)/2]))]]];

Shifting the position of a density function is easy to accomplish in the probability domain, but there are times when one might want to accomplish the operations in the transform domain, while they are a little more complicated, they are ultimately multiplication operations.

For the examples a simple symmetric stable distribution will be used.

The DFTCF may also be used to map any function in the transform domain to a discrete FFT.  Scale is the x-range in the probability domain; the range of x in the probability domain will be [-N/(2 SR), N/(2 SR)-1/SR].

sdft = DFTCF[CF1c[#1, 1.5, 0.5, 1, 0] &, 16, 8192];
conv = Chop[InverseFourier[sdft]];
g1 = ListPlot[Transpose[{XTable[16, 8192], ReOrder[conv]}], PlotRange -> {{-20, 20}, All}, Joined -> True, PlotStyle -> Blue]

sdft=DFTCF[CF1c[#1,1.5,0.5,1,0]&,16,8192];
conv=Chop[InverseFourier[sdft]];
g1=ListPlot[Transpose[{XTable[16,8192],ReOrder[conv]}],PlotRange->{{-20,20},All},Joined->True,PlotStyle->Blue]

Changing the location in the transform domain, requires multiplication by the Fourier transform of the Dirac delta function.

TrigToExp[FourierTransform[ DiracDelta[x - d], x, t]]

TrigToExp[FourierTransform[ DiracDelta[x-d],x,t]]

It is a good idea to used compiled functions in DFTCF because they always output machine precision numbers and they are fast; the FFT works with machine numbers only.  If a plain function is used, it should be wrapped with N or contain a machine precision number to ensure machine precision output, rather than a symbolic output.

shift = Compile[{t, d}, Exp[I t d]];
scale = 8192/16;
shift10 = scale DFTCF[shift[#1, -10] &, 16, 8192];(*the shift isn't scaled so it is multiplied by scale*)
conv1 = Chop[InverseFourier[ sdft shift10]];
g2 = ListPlot[Transpose[{XTable[16, 8192], ReOrder[conv1]}], PlotRange -> {{-20, 20}, All}, Joined -> True];
Show[g1, g2]

shift=Compile[{t,d},Exp[I t d]];
scale=8192/16;
shift10=scale DFTCF[shift[#1,-10]&,16,8192];(*the shift isn't scaled so it is multiplied by scale*)
conv1=Chop[InverseFourier[ sdft shift10]];
g2=ListPlot[Transpose[{XTable[16,8192],ReOrder[conv1]}],PlotRange->{{-20,20},All},Joined->True];
Show[g1,g2]

Scaling is a direct multiplication operation for the amplitude in the probability domain, but to keep the integral equal to one, the x-axis also has to be manipulated.

g2 = ListPlot[Transpose[{XTable[16, 8192] 2, ReOrder[conv]/2}], PlotRange -> {{-20, 20}, All}, Joined -> True];
Show[g1, g2]

g2=ListPlot[Transpose[{XTable[16,8192] 2,ReOrder[conv]/2}],PlotRange->{{-20,20},All},Joined->True];
Show[g1,g2]

Scaling as the discrete characteristic function is created is probably the best choice; in this case it could also be accomplished by setting the γ parameter to 2.

sdft = DFTCF[CF1c[2 #1, 1.5, 0.5, 1, 0] &, 16, 8192];
conv = Chop[InverseFourier[sdft]];
g2 = ListPlot[Transpose[{XTable[16, 8192], ReOrder[conv]}], PlotRange -> {{-20, 20}, All}, Joined -> True];
Show[g1, g2]

sdft=DFTCF[CF1c[2 #1,1.5,0.5,1,0]&,16,8192];
conv=Chop[InverseFourier[sdft]];
g2=ListPlot[Transpose[{XTable[16,8192],ReOrder[conv]}],PlotRange->{{-20,20},All},Joined->True];
Show[g1,g2]

txcolor=RGBColor[181/255,18/255,27/255];
t1 = Graphics[Text[Hyperlink[Framed[Style["Financial Home", {txcolor, Bold, Larger}]], "../map/Overview.html"], {-5, 0}]];
t2 = Graphics[Text[Hyperlink[Framed[Style["Next", {txcolor, Bold, Larger}]], "../ft04/Differentiation.html"], {0, -0.5}]];
t3 = Graphics[Text[Hyperlink[Framed[Style["Download Notebook", {txcolor, Bold, Larger}]], "../ft03/ShiftScale.nb"], {5, 0}]];
t4 = Graphics[Text[Hyperlink[Framed[Style["Previous", {txcolor, Bold, Larger}]], "../ft02/FFT.html"], {0, 0.5}]];
Show[ t1, t2, t3, t4, ImageSize -> 500]
CellPrint[TextCell["\n\n© Copyright " <> ToString[DateList[][[1]]] <> " mathestate    " <> DateString[DateList[], "DateShort"], "Text"]]

© Copyright 2008 mathestate    Fri 29 Feb 2008