Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing priors to sampler #94

Open
danielandresarcones opened this issue Sep 21, 2022 · 4 comments
Open

Passing priors to sampler #94

danielandresarcones opened this issue Sep 21, 2022 · 4 comments

Comments

@danielandresarcones
Copy link
Collaborator

I open this issue to discuss the best way of passing the priors to the sampler and avoid having to pass the whole inverse problem. From what I understand, the prior is defined in the parameter initialization, as well as the domain. The prior itself is an object of class PriorBase, whose derived classes implement a method to sample it. Right now, all the priors are defined to be SciPy priors, and the generate_samples method is implemented in the class Prior(PriorBase) for SciPy. This generate_function just calls the underlaying distribution, that is of class ProbabilityDistribution and implementes a ___call___ that evaluates the distribution. I see two options:

  1. We pass the parameter to the sampler, and the sampler calls the distribution from the parameter structure.
  2. We pass directly the distribution to the sampler.

For our purposes I cannot find many differences between the two approaches. Probably I would favour the second one for cosuming less memory, unless there are some problems that I am not seeing right now.

@joergfunger
Copy link
Member

I'm fine with both options. Though one remark. Why would we generate the samples from the initial distribution in the sampler (and not outside as done in the current implementation of Alex). This way, we would just have to pass the samples to the sampler (which are generated by creating a scipy instantiation of the prior distributions for sampling) - and potentially the bounds, but I guess in all subsequent steps of the adaptive sampler this initial pdf is not used anymore?

@danielandresarcones
Copy link
Collaborator Author

danielandresarcones commented Sep 22, 2022

If the samplers don't use the pdf information, then passing the samples is definitely a better option. @JanKoune can probably answer that better. From what I am seeing in harlow samplers, none of them seems to use the distributions at any point. However, at the same time, I cannot see that the prior distributions are considered at any point. For example, if I understood correctly, in LatinHypercube only the domain information and the number of samples are used to generate the sample set. It is based on the lhsmethod from skopt that admits a prior parameter that does not seem to be used in the current implementation, but maybe it is intended for a future one. In that case the distribution information will be needed.

@joergfunger
Copy link
Member

For LHS, this should usually consider the pdf. Only in the case of a uniform distribution, this is identical with the bounds, e.g. for normal distributions with independent variables you would decompose the sample space into equally probable subintervals (by using the inverse cdf) and then sample in that range (or take the center of the interval). Thus, if the pdf is not used, then this is not a pure LHS of the prior but using a uniform distribution using the bounds. Both options are fine, using the pdf creates more samples close to the mean, whereas the uniform sampling gives a better (equally spaced) covering of the domain.

@JanKoune
Copy link
Collaborator

JanKoune commented Sep 22, 2022

Indeed none of the samplers in Harlow use the distributions of the parameters, and only need the bounds. The harlow implementation of LHS currently assumes uniform distributions for the parameters as it was meant to be used for creating a global surrogate. For our purposes it would be fine to simply pass the initial samples to the sampler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants