({{, (RefLink[CosineWindow, paclet:ref/CosineWindow])[x]
represents a cosine window function of x.}, {, (RefLink[CosineWindow, paclet:ref/CosineWindow])[x,α]
uses the exponent α.}})

OpenersNotesSection(Spacer1)Details

(RefLink[CosineWindow, paclet:ref/CosineWindow])[x,α] is equal to (((cos(π x)))^α) for -(1/2)<x<(1/2) and 0 otherwise.

(RefLink[CosineWindow, paclet:ref/CosineWindow])[x] is equivalent to (RefLink[CosineWindow, paclet:ref/CosineWindow])[x,1].

(RefLink[CosineWindow, paclet:ref/CosineWindow]) automatically threads over lists.

OpenersPrimaryExamplesSection(Spacer1)Examples  (16)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Shape of a 1D cosine window:

Plot[CosineWindow[x],{x,-1,1}]

Shape of a 2D cosine window:

Plot3D[CosineWindow[x]CosineWindow[y],{x,-1,1},{y,-1,1},PlotRange->All]

Extract the continuous function representing the cosine window:

FunctionExpand[CosineWindow[x]]

Parameterized cosine window:

FunctionExpand[CosineWindow[x,α]]

OpenersExampleSection1(Spacer1)Scope  (6)

Shape of a 1D cosine window using a specified exponent:

Plot[CosineWindow[x,3],{x,-1,1}]

Variation of the shape as a function of the parameter α:

Plot3D[CosineWindow[x,α],{α,0,5},{x,-1,1}]

Translated and dilated cosine window:

Plot[CosineWindow[(x-1)/2],{x,-1,3}]

2D cosine window with a circular support:

Plot3D[CosineWindow[Sqrt[x^2+y^2]],{x,-1,1},{y,-1,1},PlotRange->All]

Evaluate numerically:

CosineWindow[0.1]

Discrete cosine window of length 15:

ListPlot[Array[CosineWindow,15,{-1/2,1/2}], Filling->Axis]

Discrete 15×10 2D cosine window:

ListPointPlot3D[Array[CosineWindow[#1] CosineWindow[#2]&,{15,10},{{-1/2,1/2}}], Filling->Axis]

OpenersExampleSection3(Spacer1)Applications  (3)

Create a moving-average filter of length 11:

a=ConstantArray[1/11,11]

Smooth the filter using a cosine window:

a2=#/Total[#]&[a Array[CosineWindow,11,{-1/2,1/2}]];

Log-magnitude plot of the frequency spectrum of the filters:

LogLinearPlot[Evaluate[20Log[10,Abs@ListFourierSequenceTransform[#,ω]]&/@{a,a2}],{ω,0.0314,Pi},PlotRange->All,GridLines->Automatic,ImageSize->300]

Use a window specification to calculate sample (RefLink[PowerSpectralDensity, paclet:ref/PowerSpectralDensity]):

proc=ARMAProcess[1,{.5},{.3},1];
data=RandomFunction[proc,{50}];

Calculate the spectrum:

spec=PowerSpectralDensity[data,w,CosineWindow];

Compare to spectral density calculated without a windowing function:

sd=PowerSpectralDensity[data,w];

sd===spec

The plot shows that the window smooths the spectral density:

Plot[{sd,spec},{w,-π,π},PlotRange->All,PlotLegends->{"no window","with window"}]

Compare to the theoretical spectral density of the process:

Plot[{spec,Evaluate@PowerSpectralDensity[proc,w]},{w,-π,π},PlotLegends->{"data","process"}]

Use a window specification for time series estimation:

data=RandomFunction[ARMAProcess[1,{.3},{.4},1],{300}];

Specify the window for the spectral estimator:

EstimatedProcess[data,ARMAProcess[1,1],ProcessEstimator->{"SpectralEstimator", "Window"->CosineWindow}]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

(RefLink[CosineWindow, paclet:ref/CosineWindow])[x,0] is equivalent to a Dirichlet window:

FunctionExpand[CosineWindow[x,0]]==FunctionExpand[DirichletWindow[x]]

The area under the cosine window:

area=Integrate[CosineWindow[x],{x,-∞,∞}]

Normalize to create a window with unit area:

Plot[{CosineWindow[x],CosineWindow[x]/area},{x,-1,1}]

Fourier transform of the cosine window:

f=FourierTransform[CosineWindow[x],x,w]

Power spectrum of the cosine window:

LogLinearPlot[20 Log[10,Abs[f]],{w,.1,80}]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

2D sampling of cosine window uses a different exponent for each row of samples when passed as a symbol to (RefLink[Array, paclet:ref/Array]):

Array[CosineWindow,{30,30},{{-.5,.5}}]//N//ListPlot3D

Use a pure function instead:

Array[CosineWindow[#1] CosineWindow[#2]&,{30,30},{{-1/2,1/2}}]//ListPlot3D

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Array, paclet:ref/Array])  ▪  (RefLink[TukeyWindow, paclet:ref/TukeyWindow])  ▪  (RefLink[BartlettWindow, paclet:ref/BartlettWindow])  ▪  (RefLink[BlackmanWindow, paclet:ref/BlackmanWindow])  ▪  (RefLink[HannWindow, paclet:ref/HannWindow])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Filter-Design Window Functions, paclet:guide/WindowFunctions])}})}})