View source: R/aux-functions.R
frequenciesValidator | R Documentation |
[0,\pi]
.Validation of the parameter freq
is perfomed in six steps:
Throw an error if parameter is not a vector or not numeric.
Transform each element \omega
of the vector to
[0,2\pi)
, by replacing it with
\omega \, \mbox{mod} \, 2\pi
.
Check whether all elements \omega
of the vector are
Fourier frequency 2 \pi j / T
, j \in Z
.
If this is not
the case issue a warning and round each frequency to the next
Fourier frequency of the mentioned type; the smaller one, if
there are two.
Transform each element \omega
with
\pi < \omega < 2\pi
of the vector to
[0,\pi]
, by replacing it with
2\pi - \omega
.
Check for doubles and remove all but the first appearance.
Sort in ascending order.
Any subset of the six steps can be chosen, but 1 should almost always be among the steps to be performed.
frequenciesValidator(freq, N, steps = 1:6)
freq |
the vector of frequencies to be validated. |
N |
the base of the Fourier frequencies against which the values in
|
steps |
a vector containing a subset of |
Returns a vector of Fourier frequencies that is yield by the transformations described above.
freq <- 2*pi*c(3,2,5,8,9)/10
res <- frequenciesValidator(freq, N=10, steps=1:3)
res * 10 / (2*pi) # Returns: [1] 3 2 5 8 9
res <- frequenciesValidator(freq, N=10, steps=1:4)
res * 10 / (2*pi) # Returns: [1] 3 2 5 2 1
res <- frequenciesValidator(freq, N=10, steps=1:5)
res * 10 / (2*pi) # Returns: [1] 3 2 5 1
res <- frequenciesValidator(freq, N=10, steps=1:6)
res * 10 / (2*pi) # Returns: [1] 1 2 3 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.