How to approximate a noisy spectrum

No, it’s interpreting your signal as coefficients. You need coefficients as unknown parameters and then find the ones which result in a value close to your data… Let me see if I can find an example I made…

I couldn’t find the example, but something like this:


using Turing, ApproxFun

@model fitspectrum(freqs,responses)
   mycoefs ~ MvNormal(zeros(12),10.0^2*I(12))
   fitfun = Fun(Chebyshev(),mycoefs)
   err ~ Gamma(3,0.1/2)
   responses ~ MvNormal([fitfun(freqs[i]) for i in 1:length(freqs)],err^2*I(length(responses)))
   # find the -3dB and -10dB points in the fitfun here
   return(db3=db3val, db10=db10val)
end

model = fitspectrum(myfreqs,myresponses)

ss = sample(model,NUTS(600,.8),600)

mydbvals = generated_quantities(model,ss)

1 Like