EHTJulia / StationaryRandomFields.jl

A Julia package to create noise signals following a specific power spectrum
MIT License
2 stars 0 forks source link

Make StationaryRandomFields follow either the MeasureBase or Distributions interface #4

Open ptiede opened 1 year ago

ptiede commented 1 year ago

These stationary random fields are Gaussian processes yet we do not treat them like that in this package. We should probably define the Stationary random field as a AbstractContinuousDistribution and define methods based on that. The interface is defined here [https://juliastats.org/Distributions.jl/stable/extends/](). The only thing we would need to think about is the whitening or diagonalizing parameterization of the distribution we intrinsically use here. Namely, by generating random numbers like x = FFT(PS .* z) where z are Gaussian random numbers. With this parameterization are intrinsically using a matrix square root factorization of the covariance matrix. This means that the pdf of the distribution would just be the pdf of the z but if we are calculating the pdf of the generated image we would need to calculate x inv(C) x where C is the covariance matrix. We could deal with this in a few ways the simplest would be to just enforce this parameterization from the beginning and say that logpdf(d, x) just by default uses an uncorrelated Normal distribution but rand generates the true correlated field.

The other approach that eventually we probably want to adopt is to follow MeasureBase.jl and implement these as measures and use the PushFwd measure and the transport interface to automate this over the entire Julia ecosystem. I'm a little hesitant to use it right now since it is going under a pretty large refactor but once the API stabilizes we should probably adopt this.