# What is the fftfreq sampling frequency?

From my understanding, the sampling frequency is the inverse distance between data points.
Is this correct, or do I have to use something else?

Maybe an example can make my question a bit clearer.
If I want to plot the fft spectrum what option would be correct?
`sample_rate_1`, `sample_rate_2`,or something else?

``````using FFTW, Plots

periodic(x,wavelengths) = sum(map((wl)->exp(im*2*π/wl*x),wavelengths))

n_samples = 50
x = range(1,50,length=n_samples)
range_x = maximum(x)-minimum(x)
wavelengths = rand(3:10,2)
y = periodic.(x,Ref(wavelengths))
Y = fftshift(fft(y))
sample_rate_1 = (n_samples-1)/range_x
sample_rate_2 = (n_samples)/range_x
freq_1 = fftshift(fftfreq(length(Y),sample_rate_1))
freq_2 = fftshift(fftfreq(length(Y),sample_rate_2))
p1 = begin
scatter(freq_1,abs.(Y),markersize=2,markershape=:x,title="frequency domain",label="option 1")
scatter!(freq_2,abs.(Y),markersize=2,markershape=:+,label="option 2")
vline!(1 ./wavelengths,legend=:left,label="peaks")
limit = 1/minimum(abs.(wavelengths))*1.5
xlims!(0,limit)
end

plot(plot(x,y,title="space domain",legend=false),p1,layout=(:,1))
`````` Yes.