# IFFT Scaling

**URL:** <https://discourse.julialang.org/t/ifft-scaling/33979>\
**Category:** Signal and Image Processing\
**Tags:** fftw\
**Created:** [January 30, 2020, 2:19pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979 "2020-01-30T14:19:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [January 30, 2020, 2:19pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979/1 "2020-01-30T14:19:38Z")

</div>

Does anyone know if there is a 1/N or 1/sqrt(N) scaling in the IFFT function of FFTW.jl? I am taking the IFFT of an array of complex numbers sampled from a continuous frequency domain function. The resulting time domain array seems too low in magnitude, but I don’t have actual numbers to compare it to. Have not been able to make heads or tails of source code. Below is my code. Thanks!

```julia
using Plots
using SpecialFunctions
using FFTW

#physics constants and input data
μ0 = 4*π*1e-7
σw = 3.5e7
rw = 5.6/1000
ω = collect(1:1000.0:1.0e8) #define frequency range (1 to 10^8 in increment of 1000 rad/s)

#initialize arrays
γi = zeros(ComplexF64,size(ω)[1])
Zi = copy(γi)

#Evaluate frequency domain function
γi .= sqrt.(1im.*ω*μ0*σw)
Zi .= (1/(2*π*σw*rw)) .* γi .* besseli.(0,γi*rw)./(besseli.(1,γi*rw))

fig1 = plot(ω,abs.(Zi),xaxis=:log, yaxis=:log,legend=false,lw=4)
plot!(xlabel=("Frequency [rad/s]"),ylabel=("|Z|"),fg=:black,bg=:white)
plot!(gridcolor=:black,gridwidth=2,gridstyle=:dot,gopacity = 0.8)
plot!(minorgrid=true,minorgridcolor=:black,minorgridlinewidth=1,minorgridstyle=:dot,minorgridalpha = 0.75)
plot!(xlim = (1e0,1e8),ylim = (1e-4,1e-1),size=(800,400))

#Inverse FFT
Zitime1 = ifft(Zi)

fig2 = plot(abs.(Zitime1),xlims=(1,1e8),xaxis=:log, yaxis=:log,legend=false,lw=4)
plot!(gridcolor=:black,gridwidth=2,gridstyle=:dot,gopacity = 0.8)
plot!(xlabel=("n"),ylabel=("|Z|"),fg=:black,bg=:white,size=(800,400))

display(fig1)
display(fig2)

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 30, 2020, 2:40pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979/2 "2020-01-30T14:40:57Z")

</div>

> [@jleman](#):
>
> Does anyone know if there is a 1/N or 1/sqrt(N) scaling in the IFFT function of FFTW.jl?

1/N. The forward transform (`fft`) is unscaled, and the inverse transform (`ifft`) therefore has a 1/N scaling.

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [January 30, 2020, 4:57pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979/3 "2020-01-30T16:57:46Z")

</div>

Is it necessary to create and prepend the mirror complex conjugate of the frequency domain array if all I have is the data set for positive frequency?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 30, 2020, 6:29pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979/4 "2020-01-30T18:29:30Z")

</div>

> [@jleman](#):
>
> Is it necessary to create and prepend the mirror complex conjugate of the frequency domain array if all I have is the data set for positive frequency?

Not if you use the `irfft` function.

(Note also that you can use the `bfft` or `brfft` functions if you want an unscaled transform.)

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [January 30, 2020, 7:45pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979/5 "2020-01-30T19:45:08Z")

</div>

Thanks. It is my understanding that FFT or IFFT functions generally require uniform sampling. I have a situation with logarithmic sampling of the frequency domain data set (for example 100 points per decade). Is there an ifft function that can handle that kind of input? I saw some NUFFT packages, but nothing that would handle non-integer, non-uniform spacing.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 30, 2020, 9:25pm UTC](https://discourse.julialang.org/t/ifft-scaling/33979/6 "2020-01-30T21:25:38Z")

</div>

> [@jleman](#):
>
> Is there an ifft function that can handle that kind of input?

> **[GitHub - JuliaApproximation/FastTransforms.jl: :rocket: Julia package for...](https://github.com/JuliaApproximation/FastTransforms.jl)**
>
> :rocket: Julia package for orthogonal polynomial transforms :snowboarder: - GitHub - JuliaApproximation/FastTransforms.jl: :rocket: Julia package for orthogonal polynomial transforms :snowboarder:
