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

Quickly plot marginals for parameter distribution #264

Merged
merged 1 commit into from
Mar 23, 2023
Merged

Conversation

odunbar
Copy link
Collaborator

@odunbar odunbar commented Mar 21, 2023

Purpose

Closes #254

Content

  • For the wide variety of possible distributions, the easiest general solution is to plot marginal histograms of distributions, so this is the approach we take.
  • Adds recipe for plot(pd::ParameterDistribution)
  • Adds recipe for plot(pd <: ParameterDistributionType)
  • Adds unit test which plots marginals (set ENV["CES_TEST_PLOT_OUTPUT"] = true prior to ] test)
  • Adds example into the priors docs page.

In future

I expect these can be improved upon in various ways, using other plot-types, or only plotting unique distributions where they are repeated etc. but for this PR I just wanted something simple to work on any case.

Example from test/

A complicated distribution:

d1 = Parameterized(MvNormal(zeros(4), 0.1 * I))
c1 = [no_constraint(), bounded_below(-1.0), bounded_above(0.4), bounded(-0.1, 0.2)]
name1 = "constrained_mvnormal"
u1 = ParameterDistribution(d1, c1, name1)

d2 = Samples([1 2 3 4])
c2 = [bounded(10, 15)]
name2 = "constrained_sampled"
u2 = ParameterDistribution(d2, c2, name2)
            
d3 = VectorOfParameterized(repeat([Beta(2, 2)], 3))
c3 = repeat([no_constraint()], 3)
name3 = "vector_beta"
u3 = ParameterDistribution(d3, c3, name3)
            
u = combine_distributions([u1, u2, u3])
plot(u)

plot(u, constrained=false)


  • I have read and checked the items on the review checklist.

@odunbar odunbar force-pushed the orad/plot_marginal branch 5 times, most recently from 54e53c8 to 8ab7339 Compare March 21, 2023 23:35
@odunbar
Copy link
Collaborator Author

odunbar commented Mar 22, 2023

NB: codecov doesn't like this because it only tests the PlotRecipes if plots are enabled (and github actions doesn't enable them)

@odunbar
Copy link
Collaborator Author

odunbar commented Mar 22, 2023

bors try

bors bot added a commit that referenced this pull request Mar 22, 2023
@bors
Copy link
Contributor

bors bot commented Mar 22, 2023

try

Build failed:

@odunbar
Copy link
Collaborator Author

odunbar commented Mar 22, 2023

Note that bors has succeeded on a rerun of the test suite,

it seems like an unrelated test of inflation has a slightly too-tight tolerance which is subject to failure on random-seed change - see here for the refresh:
https://github.com/CliMA/EnsembleKalmanProcesses.jl/actions/runs/4493567718

Copy link

@sandreza sandreza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look sensible to me! The only thing left is to let Bors do its thing

added plots example into docs

format

add RecipesBase

actually add file...

formatting...

rm "using plots"

format...

normalize histograms to PDF
@odunbar
Copy link
Collaborator Author

odunbar commented Mar 23, 2023

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 23, 2023

Build succeeded:

@bors bors bot merged commit 48f8568 into main Mar 23, 2023
@bors bors bot deleted the orad/plot_marginal branch March 23, 2023 00:43
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

Successfully merging this pull request may close these issues.

Plotting of parameter distribution (marginals) from a simple call
2 participants