How to model sinusoids in white gaussian noise

I was a bit curious what prior one could possibly use on the frequency and experimented a little.
It seems that if we set a uniform prior on the angle, and a strong shrinkage prior on each individual magnitude, we get an interesting prior on the functions.

import numpy as np
from scipy import stats, linalg, signal, spatial, fftpack
import matplotlib.pyplot as plt

%matplotlib inline

def polar_to_scipy(intercept, magnitude, angle):
    n = len(magnitude)
    assert len(angle) == n
    real = np.cos(angle)
    imag = np.sin(angle)
    vals = np.zeros(1 + 2 * n)
    vals[0] = intercept
    vals[1::2] = magnitude * real
    vals[2::2] = magnitude * imag
    return vals

n = 100
mag_scale = np.exp(-np.arange(n) / 20)
angle = 2 * np.pi * np.random.rand(n)
magnitude_theta = stats.halfcauchy().rvs(n)
magnitude_eta = np.abs(np.random.randn(n))
magnitude = magnitude_theta * magnitude_eta * mag_scale

plt.plot(magnitude)
y = fftpack.irfft(polar_to_scipy(0, magnitude, angle))

Random draws from this prior often look a bit like this:

image

image

No idea how happy the sampler would be about a model like this though…

@mtwest729 Obviously, I have no idea if this is even remotely interesting for your application, just playing around a little :slight_smile: