anderkve / gledeli

2 stars 0 forks source link

Discrete priors with gambit #4

Closed fzeiser closed 4 years ago

fzeiser commented 4 years ago

How can I specify a the prior for a discrete parameter? Say I want to have a flat prior over [5, 6, 7]. Is there a builtin way, or should I use some transformation myself?

anderkve commented 4 years ago

Unfortunately, there isn't a builtin way to deal with this yet. It's also a bit tricky to do the transformation from a continuous to a discrete prior, at least especially with more than two discrete states: Say you take a flat, continuous prior on [0,1] and say that (0,0.33) --> 5, (0.33,0.66) --> and (0.66, 1.0) --> 7. This would work, but it might not give 100% correct final posterior results. The choice of sampling algorithm will effectively "see" some gradually evolving "posterior" across the continuous [0,1] space as the scan progresses, and the shape of that continuous "posterior" density will probably lead to different effective probabilities for 5, 6 and 7 than you would get with an actual discrete posterior. In particular, I can imagine 6 being slightly favoured simply by the fact that (0.33, 0.66) is the middle region.

But for to begin with, I'd probably just go for the [0, 0.33, 0.66, 1.0] split above.

What do the 5, 6 and 7 represent?

fzeiser commented 4 years ago

Ah, what a pity. I thought so from the reading the ScannerBit article (Martinez2017), but had some hope ;P.

So I want to compose the nld by a combination of he discrete levels (binned) at low energy, and a model at higher energies. Let's call the energy at which we change from he discretes to the model Ecrit. The easiest way I can think of to perform this, is to create a density from the discrete levels using the same binning that we need later, so the binning of the first-generation (fg) matrix*. Then Ecrit will not be a float, but effectively be given by the binning of the fg matrix. So, say that we select a sensible region, it will run something like [1, 1.2, 1.4, .., 3.0] MeV. If I create the nld this way, there is no difference in selecting Ecrit = 1.1 or Ecrit = 1.15. As I had the feeling that this might lead to strange results in the posterior, I wondered whether there was a way of specifying a discrete prior. It could also just have been the bin number at which we make the transition.

One could argue that we don't need to follow the binning of the fg matrix, but could freely decide where to place Ecrit. However, even then, there will be discrete changes due to the nature of the discrete levels.

`* of course, at some later stage one could think about a binning free scheme; but let's stick to the "traditional" concept of comparing binned quantities, first.

anderkve commented 4 years ago

One could argue that we don't need to follow the binning of the fg matrix, but could freely decide where to place Ecrit. However, even then, there will be discrete changes due to the nature of the discrete levels.

I think simply keeping it continuous is arguably the simplest and best choice. Philosophically it's also cleaner, because it's what you naturally would do "before looking at the data", i.e. before you knew anything about binning. That the binning choices of experiments show up in the posterior is actually just the way it should be: through their binning, the experiment has in a sense "thrown away" any information on sub-binwidth lengthscales, so it's natural that this results in discrete effects in our posterior.

You could of course use some weighted sum of the discrete level and the continuous model in a E-region around Ecrit, so that nld(E) smoothly transitions from the function discrete(E) to the function model(E) across the E-range (Ecrit - eps, Ecrit + eps). So eps becomes a "smoothing parameter", where eps large (relative to bin width) leads to a smoother posterior for Ecrit.

Having a eps > 0 might help the scanning algorithm, but philosophically I'd say eps=0 is the simplest choice.

anderkve commented 4 years ago

If you want to go really fancy, I guess you could use some sort of sigmoid-like weight function that transitions between discrete(E) and model(E) only across the E-bin that Ecrit happens to fall in. To give Ecrit a continuous meaning, you could let Ecrit determine the point of 50/50 weight. So a Ecrit-value close to the upper bin edge would correspond to discrete(E) having large weight across most of the bin, and model(E) having the large weight only very close to the upper bin width.

I think that could produce a perfectly continuous posterior for Ecrit. But it might be a bit overkill. :)

fzeiser commented 4 years ago

It seems to me that this is definitively overkill with respect to the trial we want to set up here. But a nice discussion, if our project turns out to be successful.

I also wondered whether we don't waste computation time on this, if we assume that the exact placement of Ecrit is not very important. If we scan on a float, we'd have to scan a larger phase space, don't we? But anyhow, we have to live with this for now.

anderkve commented 4 years ago

Yep, I think that's right -- having a properly discrete prior would probably be more efficient.