Power Spectrum of Sinusoidal Signals​
​Authors: Housam Binous and Ahmed Bellagi

We compute the power spectra of sinusoidal signals with and without noise. Such spectra display the distribution of power contained within the signal over frequency.
This signal representation is often simpler to analyze than its time-domain counterpart.

ILLUSTRATION 1 : sinusoidal signal without white noise

In[]:=
f[x_]:=-3Cos[x]+2Cos[3x]+10.0Cos[6x]
In[]:=
Plot[{f[x]},{x,0Pi,4Pi},PlotStyleThick,FrameTrue,GridLinesAutomatic,AspectRatio1]
Out[]=
In[]:=
data1=Table[Evaluate[f[x]],{x,0,50Pi,0.01}];​​dt=0.01;​​Ni=Length[data1]-1;​​omgmax=2*(Pi/dt);​​domg=omgmax/Ni;​​omg=Table[i,{i,0,omgmax,domg}];​​fdata=Abs[Fourier[data1,FourierParameters{1,1}]];​​tbl=Transpose[{omg,fdata/Max[fdata]}];
In[]:=
p={3,2,10.}/10.
Out[]=
{0.3,0.2,1.}
In[]:=
o={1,3,6}
Out[]=
{1,3,6}
In[]:=
points=Transpose@Join[{o,p}]
Out[]=
{{1,0.3},{3,0.2},{6,1.}}
In[]:=
p2=ListPlot[tbl,JoinedTrue,FrameTrue,GridLinesAutomatic,AspectRatio1,FrameLabel{Style["frequency",16,Italic],Style["power",16,Italic]},PlotRange{{0,10},{0,1.2}},PlotStyle{Brown,Thick},Epilog{PointSize[0.02],Darker@Blue,Point[points[[1]]],Point[points[[2]]],Point[points[[3]]]}]
Out[]=

ILLUSTRATION 2 : sinusoidal signal without noise

In[]:=
f[x_]:=-3.24Cos[3x]-2.14Sin[0.4x]+10.0Cos[4x]-7Sin[8.45x]
In[]:=
Plot[{f[x]},{x,0Pi,4Pi},PlotStyleThick,FrameTrue,GridLinesAutomatic,AspectRatio1]
Out[]=
In[]:=
data1=Table[Evaluate[f[x]],{x,0,1000Pi,0.01}];​​dt=0.01;​​Ni=Length[data1]-1;​​omgmax=2*(Pi/dt);​​domg=omgmax/Ni;​​omg=Table[i,{i,0,omgmax,domg}];​​fdata=Abs[Fourier[data1,FourierParameters{1,1}]];​​tbl=Transpose[{omg,fdata/Max[fdata]}];
In[]:=
p={3.24,10,2.14,7.}/10.
Out[]=
{0.324,1.,0.214,0.7}
In[]:=
o={3,4,0.4,8.45}
Out[]=
{3,4,0.4,8.45}
In[]:=
points=Transpose@Join[{o,p}]
Out[]=
{{3,0.324},{4,1.},{0.4,0.214},{8.45,0.7}}
In[]:=
p2=ListPlot[tbl,JoinedTrue,FrameTrue,GridLinesAutomatic,AspectRatio1,FrameLabel{Style["frequency",16,Italic],Style["power",16,Italic]},PlotRange{{0,10},{0,1.2}},PlotStyle{Brown,Thick},Epilog{PointSize[0.02],Darker@Blue,Point[points[[1]]],Point[points[[2]]],Point[points[[3]]],Point[points[[4]]]}]
Out[]=

ILLUSTRATION 3 : sinusoidal signal with noise
​One gets the same spectrum as illustration 1 however the baseline has noise.

In[]:=
SeedRandom[1234]
In[]:=
data=Table[{x,-3Cos[x]+2Cos[3x]+10.0Cos[6x]+15RandomReal[{-1,1}]},{x,0,50Pi,0.01}]
Out[]=
{{0.,20.2983},{0.01,9.64018},{0.02,-3.48821},{0.03,5.16908},{0.04,-5.94927},{0.05,21.3526},{0.06,9.64476},{0.07,7.47425},{0.08,0.182697},{0.09,15.3137},
⋯15688⋯
,{156.98,2.15493},{156.99,15.7789},{157.,1.26979},{157.01,9.92195},{157.02,18.8646},{157.03,4.21874},{157.04,6.64014},{157.05,3.23296},{157.06,5.95403},{157.07,1.6969}}
large output
show less
show more
show all
set size limit...