Computes Fourier frequencies for various types of inputs, such as scalars, vectors, matrices, time series, or arrays. This generic function dispatches appropriate methods based on the input type.
Usage
fourier_frequencies(x)
# Default S3 method
fourier_frequencies(x)
# S3 method for class 'ts'
fourier_frequencies(x)
# S3 method for class 'array'
fourier_frequencies(x)
Details
This function has the following methods:
Default Input (
fourier_frequencies.default
): Computes normalized Fourier frequencies for scalar or vector inputs.Time Series Input (
fourier_frequencies.ts
): Computes frequencies scaled by the frequency attribute of ats
object.Multidimensional Arrays (
fourier_frequencies.array
): Computes frequencies for each dimension of a matrix or array.
See the examples for details on each case.
Examples
# Default input (vector)
fourier_frequencies(8)
#> # A tibble: 8 × 1
#> .dim_1
#> <dbl>
#> 1 0
#> 2 0.125
#> 3 0.25
#> 4 0.375
#> 5 0.5
#> 6 -0.375
#> 7 -0.25
#> 8 -0.125
# Time series input
ts(rnorm(36), frequency = 12) |> fourier_frequencies()
#> # A tibble: 36 × 1
#> .dim_1
#> <dbl>
#> 1 0
#> 2 0.333
#> 3 0.667
#> 4 1
#> 5 1.33
#> 6 1.67
#> 7 2
#> 8 2.33
#> 9 2.67
#> 10 3
#> # ℹ 26 more rows
# Multidimensional array input
array(1:27, dim = c(3, 3, 3)) |> fourier_frequencies()
#> # A tibble: 27 × 3
#> .dim_1 .dim_2 .dim_3
#> <dbl> <dbl> <dbl>
#> 1 0 0 0
#> 2 0.333 0 0
#> 3 -0.333 0 0
#> 4 0 0.333 0
#> 5 0.333 0.333 0
#> 6 -0.333 0.333 0
#> 7 0 -0.333 0
#> 8 0.333 -0.333 0
#> 9 -0.333 -0.333 0
#> 10 0 0 0.333
#> # ℹ 17 more rows
# Matrix input
matrix(1:9, nrow = 3, ncol = 3) |> fourier_frequencies()
#> # A tibble: 9 × 2
#> .dim_1 .dim_2
#> <dbl> <dbl>
#> 1 0 0
#> 2 0.333 0
#> 3 -0.333 0
#> 4 0 0.333
#> 5 0.333 0.333
#> 6 -0.333 0.333
#> 7 0 -0.333
#> 8 0.333 -0.333
#> 9 -0.333 -0.333