bayesiains / nflows

Normalizing flows in PyTorch
MIT License
833 stars 119 forks source link

Flow for one-dimensional data #73

Closed scutzck033 closed 1 year ago

scutzck033 commented 1 year ago

Thank you very much for sharing the code. I wonder whether the autoregressive flows (e.g., MAF) can be used to estimate the density of one-dimensional data? If not, which kind of flow model can be used?

imurray commented 1 year ago

The meaning of "Autoregressive flow" is that each dimension is modeled given the previous ones. In standard MAF the univariate model is a Gaussian, and in 1D you'd be fitting a single univariate Gaussian, conditioned on nothing, and should just do that more directly.

A generalization of a single Gaussian is a mixture of Gaussians. If you want that to be a conditional model, it's a "mixture density network". Another way to flexibly warp 1D data is to use a spline transformation, supported by this library.

I'd only use neural network technology if your distribution is conditioned on something interesting, and you're looking for a good output layer. If you're literally fitting just a 1D distribution, I'd consider a histogram.

scutzck033 commented 1 year ago

Many thanks for your answer! It helps a lot!