({{, (RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity])[data,ω]
estimates the power spectral density for data.}, {, (RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity])[data,ω,sspec]
estimates the power spectral density for data with smoothing specification sspec.}, {, (RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity])[tproc,ω] 
represents the power spectral density of a time series process tproc.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity]) is also known as the energy spectral density.

(RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity])[tproc,ω] is defined for weakly stationary time series processes as (∑_(h==-∞)^∞)r(h)(e^(-i h ω)), where r(h) denotes (RefLink[CovarianceFunction, paclet:ref/CovarianceFunction])[proc,h].

The following smoothing specifications sspec can be given:

For a window function w and positive integer c, (RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity])[data,ω,{c,w}] is computed as (∑_(h==-c)^c)r(h) w(h/2c)(e^(-i h ω)), where r(h) is defined as (RefLink[CovarianceFunction, paclet:ref/CovarianceFunction])[data,h].

By default, the cutoff c is chosen to be n-1, where n is the length of data, and the window function is (RefLink[DirichletWindow, paclet:ref/DirichletWindow]).

A window function w(x) is an even function such that w(0)==1, (Abs[w(x)])≤1, w(x)==0 for (Abs[x])>1/2, including standard windows such as (RefLink[HammingWindow, paclet:ref/HammingWindow]), (RefLink[ParzenWindow, paclet:ref/ParzenWindow]), etc.

A window function can be given as a list of values {(Subscript[w, 0]),…}, where -1≤(Subscript[w, i])≤1, and it will be applied symmetrically in the vector case.

(RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity]) takes the (RefLink[FourierParameters, paclet:ref/FourierParameters]) option. Common settings for (RefLink[FourierParameters, paclet:ref/FourierParameters]) include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (32)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Estimate the power spectral density for some data:

PowerSpectralDensity[Range[10],ω]

Calculate the power spectral density for a univariate time series:

PowerSpectralDensity[ARProcess[{a},(σ^2)],ω]

The sample power spectral density for a random sample from autoregressive time series:

data=RandomFunction[ARProcess[{.2},.1],{1,1000}];

Calculate power spectral density with cutoff:

cutoffs={5,10,17};
spec=Table[PowerSpectralDensity[data,ω,i],{i,cutoffs}];

Plot[Evaluate@spec,{ω,-π,π},PlotLegends->cutoffs]

OpenersExampleSection1(Spacer1)Scope  (14)

OpenersExampleSubsection0(Spacer1)Empirical Estimates  (4)

Estimate the power spectral density for a univariate time series:

data=TimeSeries[];

PowerSpectralDensity[data,ω]

Plot[%,{ω,-π,π},Filling->Axis,PlotRange->All]

Power spectral density for a vector time series:

data=TimeSeries[];

psd=PowerSpectralDensity[data,ω]//Simplify

Power spectral density for each component:

Table[Plot[psd[[i,i]],{ω,-π,π}],{i,1,2}]

Cross power spectral density between components:

Table[ParametricPlot[{Re[#],Im[#]}&@psd[[i,Mod[i,2]+1]],{ω,-π,π},ColorFunction->Function[{x,y,ω},(ColorData["Rainbow"][ω])]],{i,1,2}]

Estimate the power spectral density for an ensemble of paths:

data=RandomFunction[ARProcess[{.8},1],{0,100},5];

psd=PowerSpectralDensity[data,ω];

Plot[psd,{ω,-π,π},PlotRange->All,Filling->Axis]

Compare empirical and theoretical power spectral densities functions:

proc=MAProcess[{.4,.3,.5,.6,.3},1.];

data=RandomFunction[proc,{0,10^2}];

Plot[#,{ω,-π,π},Filling->Axis,PlotRange->All]&/@{PowerSpectralDensity[proc,ω],PowerSpectralDensity[data,ω]}

OpenersExampleSubsection1(Spacer1)Smoothing  (5)

Obtain a smoothed estimate using a cutoff at 5:

data=Range[10];

sspec=PowerSpectralDensity[data,ω,5]

Compare the smoothed spectrum to the original:

Plot[{Evaluate@PowerSpectralDensity[data,ω],sspec},{ω,-π,π},Filling->Axis,PlotRange->All]

Compute the power spectral density using a (RefLink[NuttallWindow, paclet:ref/NuttallWindow]):

data=Range[10];

sspec=PowerSpectralDensity[data,ω,NuttallWindow]

Compare the smoothed spectrum to the original:

Plot[{Evaluate@PowerSpectralDensity[data,ω],sspec},{ω,-π,π},Filling->Axis,PlotRange->All]

Define a window using a pure function:

data=Range[10];

sspec=PowerSpectralDensity[data,ω,HannPoissonWindow[#,(1/2)]&]

Compare the smoothed spectrum to the original:

Plot[{Evaluate@PowerSpectralDensity[data,ω],sspec},{ω,-π,π},Filling->Axis,PlotRange->All]

Estimate the power spectral density using specified window function values:

n=10;
data=Range[n];
win=TukeyWindow[((#)/(2*(n-1))),(1/3)]&/@Range[0,n-1];

Compare to power spectral density with explicit (RefLink[TukeyWindow, paclet:ref/TukeyWindow]):

PowerSpectralDensity[data,ω,win]===PowerSpectralDensity[data,ω,TukeyWindow]

Compare the smoothed spectrum to the original:

Plot[{Evaluate@PowerSpectralDensity[data,ω],Evaluate@PowerSpectralDensity[data,ω,TukeyWindow]},{ω,-π,π},Filling->Axis,PlotRange->All]

Compute the power spectral density, given a cutoff and a window function:

data=Range[10];

sspec=PowerSpectralDensity[data,ω,{5,BartlettWindow}]

Compare the smoothed spectrum to the original:

Plot[{Evaluate@PowerSpectralDensity[data,ω],sspec},{ω,-π,π},Filling->Axis,PlotRange->All]

OpenersExampleSubsection2(Spacer1)Random Processes  (5)

Power spectral density for an (RefLink[ARProcess, paclet:ref/ARProcess]):

proc[a_]=ARProcess[{a},1];

Plot[PowerSpectralDensity[#,w],{w,-π,π},Filling->Axis,PlotRange->All]&/@{proc[0.8],proc[-0.8]}

PowerSpectralDensity[proc[a],w]

Vector (RefLink[ARProcess, paclet:ref/ARProcess]):

a={{1/7,0},{1/3,0}};
Σ={{1,-1/3},{-1/3,1}};
proc=ARProcess[{a},Σ];

psd=PowerSpectralDensity[proc,ω];
psd//MatrixForm

Cross spectral density:

ParametricPlot[{Re[#],Im[#]}&@psd[[1,2]],{ω,-π,π},ColorFunction->Function[{x,y,ω},(ColorData["Rainbow"][ω])]]

Power spectral density for an (RefLink[MAProcess, paclet:ref/MAProcess]):

proc[b_]=MAProcess[{b},1];

Plot[PowerSpectralDensity[#,w],{w,-π,π},Filling->Axis]&/@{proc[0.9],proc[-0.9]}

PowerSpectralDensity[proc[b],w]

Vector (RefLink[MAProcess, paclet:ref/MAProcess]):

a={{1/10,0},{1/3,0}};
Σ={{1,1/3},{1/3,1}};
proc=MAProcess[{a},Σ];

psd=PowerSpectralDensity[proc,ω];
psd//MatrixForm

Cross spectral density:

ParametricPlot[{Re[#],Im[#]}&@psd[[1,2]],{ω,-π,π},ColorFunction->Function[{x,y,ω},(ColorData["Rainbow"][ω])],AspectRatio->1]

Power spectral density for an (RefLink[ARMAProcess, paclet:ref/ARMAProcess]):

proc[a_,b_]=ARMAProcess[{a},{b},1];

Plot[PowerSpectralDensity[#,w],{w,-π,π},Filling->Axis,PlotRange->All]&/@{proc[0.3,0.2],proc[-0.3,-0.2]}

PowerSpectralDensity[proc[a,b],w]

Vector (RefLink[ARMAProcess, paclet:ref/ARMAProcess]):

a={{1/9,0},{1/3,1/2}};
b={{1,3/4},{1/2,-1/4}};
Σ={{1,1/3},{1/3,1}};
proc=ARMAProcess[{a},{b},Σ];

psd=PowerSpectralDensity[proc,ω];
psd//FullSimplify//MatrixForm

Cross spectral density:

ParametricPlot[{Re[#],Im[#]}&@psd[[1,2]],{ω,-π,π},ColorFunction->Function[{x,y,ω},(ColorData["Rainbow"][ω])],AspectRatio->1]

Power spectral density for a fractionally integrated time series:

Plot[PowerSpectralDensity[FARIMAProcess[{.3,-.2},-.4,{1},1],w],{w,-π,π},Filling->Axis,PlotRange->All]

PowerSpectralDensity[FARIMAProcess[{.3,.2},.4,{1},1],w]

Vector (RefLink[FARIMAProcess, paclet:ref/FARIMAProcess]):

a={{1/9,0},{1/3,1/2}};
b={{1,1/4},{1/2,0}};
Σ={{1,0},{0,1}};
proc=FARIMAProcess[{a},{1/3,-1/4},{b},Σ];

psd=PowerSpectralDensity[proc,ω];
psd//FullSimplify//MatrixForm

Cross spectral density:

ParametricPlot[{Re[#],Im[#]}&@psd[[1,2]],{ω,-π,π},ColorFunction->Function[{x,y,ω},(ColorData["Rainbow"][ω])],AspectRatio->1]

Power spectral density for a seasonal time series:

Plot[PowerSpectralDensity[SARMAProcess[{.2},{.4},{12,{.3},{1}},1],w],{w,-π,π},Filling->Axis]

PowerSpectralDensity[SARMAProcess[{a},{b},{12,{g},{h}},(σ^2)],ω]

Vector (RefLink[SARMAProcess, paclet:ref/SARMAProcess]):

a={{1/9,0},{1/3,1/2}};
b={{1/3,1/4},{1/2,0}};
Σ={{1,0},{0,1}};
proc=SARMAProcess[{},{b},{4,{b},{}},Σ];

psd=PowerSpectralDensity[proc,ω];
psd//FullSimplify//MatrixForm

Cross spectral density:

ParametricPlot[{Re[#],Im[#]}&@psd[[1,2]],{ω,-π,π},ColorFunction->Function[{x,y,ω},(ColorData["Rainbow"][ω])],AspectRatio->1]

OpenersExampleSection2(Spacer1)Options  (2)

The default value of (RefLink[FourierParameters, paclet:ref/FourierParameters]):

PowerSpectralDensity[Range[10],ω,FourierParameters->{1,1}]

PowerSpectralDensity[Range[10],ω]

%-%%

Change (RefLink[FourierParameters, paclet:ref/FourierParameters]):

PowerSpectralDensity[Range[10],ω,FourierParameters->{-1,1}]

It is the default value scaled:

PowerSpectralDensity[Range[10],ω]

%/%%//Simplify

OpenersExampleSection3(Spacer1)Applications  (1)

Use power spectral density for estimating time series processes:

data=RandomFunction[ARProcess[{.3,.2},1],{10^3}];

EstimatedProcess[data,ARProcess[2],ProcessEstimator->"SpectralEstimator"]

Use a smoothing window:

EstimatedProcess[data,ARProcess[2],ProcessEstimator->{"SpectralEstimator","Window"->5}]

OpenersExampleSection4(Spacer1)Properties & Relations  (11)

Power spectral density of a time series is a transform of the (RefLink[CovarianceFunction, paclet:ref/CovarianceFunction]):

proc=ARProcess[c,{a},(σ^2)];
cf=CovarianceFunction[proc,h]

Use (RefLink[FourierSequenceTransform, paclet:ref/FourierSequenceTransform]):

ft=FourierSequenceTransform[cf,h,z]

Compare to the power spectrum:

PowerSpectralDensity[proc,z]

FullSimplify[%-ft]

For a vector time series:

proc=ARProcess[{{{1/3,11/10},{1/5,1/10}}},{{1,0},{0,1}}];

cov=CovarianceFunction[proc,h]//PiecewiseExpand;

fst=FourierSequenceTransform[cov,h,w]

fst-PowerSpectralDensity[proc,w]//Simplify

Power spectral density of data is a transform of the sample (RefLink[CovarianceFunction, paclet:ref/CovarianceFunction]):

sample=Range[20];
n=Length[sample];
cov=CovarianceFunction[sample,{-n+1,n-1}];

Apply (RefLink[ListFourierSequenceTransform, paclet:ref/ListFourierSequenceTransform]):

ListFourierSequenceTransform[cov,w,-n+1]//Simplify

Compare to SamplePowerSpectralDensity:

PowerSpectralDensity[sample,w]//Simplify

%-%%//FullSimplify

For a vector values time series:

data=RandomFunction[ARProcess[{{{.3,.1},{.2,.1}}},{{1,0},{0,1}}],{10}];
n=data["PathLength"];

cov=CovarianceFunction[data,{-n+1,n-1}]["Values"];

lfst=Table[ListFourierSequenceTransform[cov[[All,i,j]],w,-n+1],{i,1,2},{j,1,2}]

PowerSpectralDensity[data,w]-lfst//Simplify//Chop

Power spectrum of white noise:

FourierSequenceTransform[Piecewise[{{1,x==0}},0],x,w]

Compare to special case of an (RefLink[MAProcess, paclet:ref/MAProcess]):

AbsoluteCorrelationFunction[MAProcess[{},1],h]

PowerSpectralDensity[MAProcess[{},1],w]

Integrate to find the variance:

Integrate[PowerSpectralDensity[ARProcess[{a},(σ^2)],w,FourierParameters->{-1,1}],{w,-π,π},Assumptions->σ>0&&-1≤a≤1]

Compare to the variance of the time series:

CovarianceFunction[ARProcess[{a},(σ^2)],0]

%-%%//Simplify

Integrate to find the sample second moment:

data=TimeSeries[];

NIntegrate[PowerSpectralDensity[data,w,FourierParameters->{-1,1}],{w,-π,π}]

Compare to the sample second moment:

CovarianceFunction[data,0]

%-%%//Chop

Power spectral density for harmonic frequencies is related to (RefLink[PeriodogramArray, paclet:ref/PeriodogramArray]):

data=Range[20];
n=Length[data];
spec=Table[PowerSpectralDensity[data,2π j/n],{j,0,n-1}]//N

Compare with (RefLink[PeriodogramArray, paclet:ref/PeriodogramArray]):

periodogram=PeriodogramArray[data]

For zero frequency:

First[periodogram]-n*Mean[data]^2

For nonzero frequencies:

Rest[spec]-Rest[periodogram]//Chop

Diagonal elements of the power spectral density for vector data:

data=TimeSeries[];

data["ValueDimensions"]

psd=PowerSpectralDensity[data,ω];

Compare to univariate power spectral density for each data component:

dens=Table[PowerSpectralDensity[data["Values"][[All,i]],ω],{i,2}];

Table[Plot[{psd[[i,i]],dens[[i]]},{ω,-π,π},PlotStyle->{Automatic, Dotted},PlotLegends->{"Vector Component","Univariate"}],{i,2}]

Power spectral density of a vector process is conjugate symmetric about zero:

proc=ARProcess[{{{1/3,1/10},{1/5,1/10}}},{{1,0},{0,1}}];

Conjugate/@PowerSpectralDensity[proc,-2]

PowerSpectralDensity[proc,2]

%-%%

Power spectral density of a univariate process is symmetric about zero:

proc=ARMAProcess[{a},{b},(σ^2)];

PowerSpectralDensity[proc,w]==PowerSpectralDensity[proc,-w]

Power spectral density of a vector process is Hermitian:

proc=ARMAProcess[{{{1/3,1/10},{1/5,1/10}}},{{{1/8,-3/10},{3/5,1/6}}},{{1,-.3},{-.3,1}}];

HermitianMatrixQ[PowerSpectralDensity[proc,RandomReal[{-π,π}]]]

Also non-negative definite:

PositiveSemidefiniteMatrixQ[PowerSpectralDensity[proc,RandomReal[{-π,π}]]]

The magnitude of the sample cross spectral density is given by each component:

data=EventSeries[];

data["ValueDimensions"]

psd=PowerSpectralDensity[data,3]//Chop

Abs[psd[[1,2]]]^2-Times@@Diagonal[psd]

The determinant of the sample power spectral density is constant equal to zero:

FindMaximum[Abs@Det[PowerSpectralDensity[data,w]],{w,-3,3}]

Use (RefLink[TransferFunctionModel, paclet:ref/TransferFunctionModel]) to calculate (RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity]) of a time series:

proc=ARMAProcess[{a},{b},(σ^2)];
psd[ω_]=PowerSpectralDensity[proc,ω]

Define transfer function:

g[z_]=TransferFunctionModel[proc][z][[1,1]]

Calculate spectral density:

(σ^2)g[Exp[I ω]]g[Exp[-I ω]]//ComplexExpand//TrigExpand//Simplify

Check:

%-psd[ω]//Simplify

OpenersExampleSection5(Spacer1)Neat Examples  (1)

Plot a product of two power spectral densities in 3D:

proc=SARMAProcess[{.2},{.4},{24,{.3},{.1}},1];
Plot3D[Evaluate[PowerSpectralDensity[proc,w]*PowerSpectralDensity[proc,z]],{w,-π,π},{z,-π,π},PlotRange->All,ColorFunction->"IslandColors",ViewPoint->{-3,3,.5}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[PeriodogramArray, paclet:ref/PeriodogramArray])  ▪  (RefLink[AbsoluteCorrelationFunction, paclet:ref/AbsoluteCorrelationFunction])  ▪  (RefLink[CovarianceFunction, paclet:ref/CovarianceFunction])  ▪  (RefLink[FourierSequenceTransform, paclet:ref/FourierSequenceTransform])  ▪  (RefLink[WeakStationarity, paclet:ref/WeakStationarity])  ▪  (RefLink[ARMAProcess, paclet:ref/ARMAProcess])  ▪  (RefLink[SARIMAProcess, paclet:ref/SARIMAProcess])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Fourier Analysis, paclet:guide/FourierAnalysis])}, {▪(RefLinkPlain[Time Series Processing, paclet:guide/TimeSeries])}, {▪(RefLinkPlain[Time Series Processes, paclet:guide/TimeSeriesProcesses])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(Spacer1)▪(RefLinkPlain[(Spacer1)Window Functions, paclet:guide/WindowFunctions])}, {(Spacer1)▪(RefLinkPlain[(Spacer1)Time Series Processes, paclet:guide/TimeSeriesProcesses])}})}})