Skip to content

pmf values = 0 cause cut-out regions in plots #12

@Stefan-Heimersheim

Description

@Stefan-Heimersheim

Describe the bug
I have a sample from my prior (all weights = 1) of a interpolation function (FlexKnot, free-form parameterization etc.) and plot them using fgivenx. (Lists, as I have multiple, evidence-weighted, samples.)

cbar = fgivenx.plot_contours(function_list, zplot, chain_list, ax=ax, weights=weight_list, logZ=logZ_list, cache=cachestr, contour_line_levels=[1,2], fineness=0.2, smooth=0)

and I get plots like these (different sample sizes, 3rd different fineness/levels):
bug2
bug1
bug3

Did you see something like this before? Is it just too small sample size or is there some issue computing the pmfs?

The plots break due to infinite values (erfinv(1)) of z=0(pmf=0) in plot.py, plot(). Setting inf to 1e10 allows the lines to be plotted but does not fix the issue of why the pmf is computed as 0.

# Convert to sigmas
infs = numpy.where(z==0)
z = numpy.sqrt(2) * scipy.special.erfinv(1 - z)
z[infs] = 1e10

bug4
Adding e.g. smooth=2 does not improve the situation (here applied to the 2nd plot, with the z[infs] = 1e10 "fix", it makes the cut-out larger as it seems to propagate the problem over the smoothing area):
smooth2
Edit: I just noticed the smoothing code, of course it cannot work as the smoothing is applied to the contours (where I have put an 1e10) and not the PDF

I'm not sure if the problem is due to my sample size (1st plot 1e5 samples, 2nd plot 1e4) or some issue, plotting for 1e5 samples however already takes an hour so it is not really feasible to increase the sample size much.

To Reproduce
If you think this is an important bug I can work out an MWE; right now I was mainly wondering if this is a common problem you see often or something that shouldn't happen.

Expected behavior
a) Smooth contours (physics dependent)
b) Continuous contour lines (by definition)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions