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

constrained_gaussian freezes #261

Closed
sdwfrost opened this issue Mar 17, 2023 · 3 comments
Closed

constrained_gaussian freezes #261

sdwfrost opened this issue Mar 17, 2023 · 3 comments
Assignees

Comments

@sdwfrost
Copy link

The following code runs, but freezes - I suspect this is due to the choice of parameters, but no warning/error is thrown.

using EnsembleKalmanProcesses
using EnsembleKalmanProcesses.ParameterDistributions
constrained_gaussian("gamma", 0.5, 0.5, 0.0, 1.0)
@odunbar
Copy link
Collaborator

odunbar commented Mar 17, 2023

Thanks for pointing this out! Indeed, this is trying to create a bounded distribution within [0,1] but with mean of 0.5 and a standard deviation of 0.5. which hits the boundary.

For more outlandish values e.g. constrained_gaussian("gamma", 0.5, 0.8, 0.0, 1.0) it seems like our failsafe kicks in with an error.

But i guess for this value of sd (and some nearby), it tries to solve it without success.

Quick solves for you

  • Using constrained_gaussian("gamma", 0.5, 0.4, 0.0, 1.0) Will put a lot of mass at the boundaries, (mu=1e-5, sig=4.06 this is even more extreme than e.g. the sig = 3.16 in the figure below)
  • constrained_gaussian("gamma", 0.5, 0.3, 0.0, 1.0) Will create something close to uniform (mu=1e-5, sig=1.81 c.f. fig below)
    image
    [from wikipedia logitnormal page]

https://en.wikipedia.org/wiki/Logit-normal_distribution

Actions

  • I'll see if we can tighten up the error message tolerance
  • in future we can improve the numerical solver robustness.

@odunbar odunbar mentioned this issue Mar 23, 2023
1 task
@odunbar odunbar self-assigned this Mar 23, 2023
bors bot added a commit that referenced this issue Mar 23, 2023
266: Small bug fixes in tests r=odunbar a=odunbar

<!--- THESE LINES ARE COMMENTED -->
## Purpose 
<!--- One sentence to describe the purpose of this PR, refer to any linked issues:
#14 -- this will link to issue 14
Closes #2 -- this will automatically close issue 2 on PR merge
-->
- Closes #265 
- Addresses #261 (1/2)
Leads to a more robust test pipeline and constructor `constrained_gaussian`

## Content
<!---  specific tasks that are currently complete 
- Solution implemented
-->
- fixes bugs within #265 ,
- resolves an eks object bug where it would mix prior and final ensemble, and now puts plots in the EKP test subdirectory
- adds warning for when users prescribe values in `constrained_gaussian` which will be slow to solve. In these cases a large amount of mass will be concentrated on the boundary.
- tightens error of termination to `mu + sig < upper_bound`  (before was `mu + 0.7*sig > 1` etc.) likewise for lower bound

<!---
Review checklist

I have:
- followed the codebase contribution guide: https://clima.github.io/ClimateMachine.jl/latest/Contributing/
- followed the style guide: https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/
- followed the documentation policy: https://github.com/CliMA/policies/wiki/Documentation-Policy
- checked that this PR does not duplicate an open PR.

In the Content, I have included 
- relevant unit tests, and integration tests, 
- appropriate docstrings on all functions, structs, and modules, and included relevant documentation.

-->

----
- [x] I have read and checked the items on the review checklist.


Co-authored-by: odunbar <[email protected]>
@odunbar
Copy link
Collaborator

odunbar commented Apr 3, 2023

Closing, now tolerances are sorted, and warning message implemented if solver will struggle.

@odunbar odunbar closed this as completed Apr 3, 2023
@odunbar
Copy link
Collaborator

odunbar commented Apr 3, 2023

PR #266

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

2 participants