plotutils Package

plotutils Module

plotutils.plotutils.decorrelated_2d_histogram_pdf(pts, xmin=None, xmax=None, ymin=None, ymax=None)[source]

Returns (XS, YS, ZS), with ZS of shape (Nx,Ny) and XS and YS of shape (Nx+1,Ny+1) giving the height and box corners, respectively, of the histogram estimate of the PDF from which pts are drawn. The bin widths and orientations are chosen optimally for the convergence of the histogram to the true PDF under a squared-error metric; the automatic binning is tuned to work particularly well for multivariate Gaussians.

Note: the first index of ZS varies with the X coordinate, while the second varies with the y coordinate. This is consistent with pp.pcolor(), but inconsistent with pp.imshow() and pp.contour().

Parameters:
  • pts – The sample points, of shape (Npts,2).
  • xmin – Minimum value in x. If None, use minimum data value.
  • xmax – Maximum value in x. If None, use minimum data value.
  • ymin – Minimum value in y. If None, use minimum data value.
  • ymax – Maximum value in y. If None, use minimum data value.
plotutils.plotutils.greedy_kde_areas_2d(pts, levels, Nx=100, Ny=100, truth=None)[source]

Returns an estimate of the area within the given credible levels for the posterior represented by pts.

The algorithm uses a two-step process (see this document) so that the resulting credible areas will be unbiased.

Parameters:
  • pts – An (Npts, 2) array giving samples from the posterior. The algorithm assumes that each point is an independent draw from the posterior.
  • levels – The credible levels for which the areas are desired.
  • Nx – The number of subdivisions along the first parameter to be used for the credible area integral.
  • Ny – The number of subdivisions along the second parameter to be used for the credible area integral.
  • truth – If given, then the area contained within the posterior contours that are more probable than the posterior evaluated at truth will be returned. Also, the credible level that corresponds to truth is returned. The area quantity is sometimes called the ‘searched area’, since it is the area a greedy search algorithm will cover before finding the true values.
Returns:

If truth is None, areas, an array of the same shape as levels giving the credible areas; if truth is not None then (areas, searched_area, p_value).

plotutils.plotutils.interpolated_quantile(sorted_pts, quantile)[source]

Returns a linearly interpolated quantile value.

Parameters:
  • sorted_pts – A sorted array of points.
  • quantile – The quantile desired.
plotutils.plotutils.load_header_data(file, header_commented=False)[source]

Load data from the file, using header for column names.

Parameters:
  • file – A file object or filename.
  • header_commented – If True, discard the first character of header as comment marker.
plotutils.plotutils.plot_cumulative_distribution(pts, *args, **kwargs)[source]

Plots the 1D normalized empirical CDF for the given points. Additional arguments are passed to matplotlib’s plot.

plotutils.plotutils.plot_emcee_chains(chain, truths=None, mean=True, fburnin=0)[source]

Produces a chain plot of the mean values of each variable at each step. The chain should have the shape (nwalkers, nsteps, nvars), and the resulting grid of plots will be as close to square as possible, showing the mean walker position at each step.

Parameters:
  • chain – An array of shape (nwalkers, nsteps, nvars) giving the history of the chain.
  • truths – Either None or an iterable giving the truth values for each of the parameters, which will be plotted as a horizontal line.
  • mean – If True (default) plot only the mean of the walker ensemble. Otherwise, plot the evolution of each walker in the chain.
  • fburnin – The fraction of points to discard at the beginning of the chain.
plotutils.plotutils.plot_emcee_chains_one_fig(chain, fburnin=None)[source]

Plots a single-figure representation of the chain evolution of the given chain. The figure shows the evolution of the mean of each coordinate of the ensemble, normalised to zero-mean, unit-standard deviation.

Parameters:
  • chain – The sampler chain, of shape (nwalkers, niter, nparams)
  • fburnin – If not None, refers to the fraction of samples to discard at the beginning of the chain.
plotutils.plotutils.plot_greedy_histogram_interval_2d(pts, levels, xmin=None, xmax=None, ymin=None, ymax=None, Nx=100, Ny=100, cmap=None, colors=None, *args, **kwargs)[source]

Plot probability interval contours estimated from a histogram PDF of the given points. The number of bins in each dimension is chosen optimally for minimizing the squared error with a Gaussian PDF. Additional arguments passed to pp.contour().

Parameters:
  • pts – Shape (Npts, 2) array of samples.
  • levels – The probability interval levels to plot.
  • xmin – Minimum value in x. If None, use minimum data value.
  • xmax – Maximum value in x. If None, use minimum data value.
  • ymin – Minimum value in y. If None, use minimum data value.
  • ymax – Maximum value in y. If None, use minimum data value.
  • Nx – Number of divisions in x for contour resolution.
  • Ny – Number of divisions in y for contour resolution.
  • cmap – See pp.contour().
  • colors – See pp.contour().
plotutils.plotutils.plot_greedy_kde_interval_2d(pts, levels, xmin=None, xmax=None, ymin=None, ymax=None, Nx=100, Ny=100, cmap=None, colors=None, *args, **kwargs)[source]

Plots the given probability interval contours, using a greedy selection algorithm. Additional arguments passed to pp.contour().

The algorithm uses a two-step process (see this document) so that the resulting credible areas will be unbiased.

Parameters:
  • pts – Array of shape (Npts, 2) that contains the points in question.
  • levels – Sequence of levels (between 0 and 1) of probability intervals to plot.
  • xmin – Minimum value in x. If None, use minimum data value.
  • xmax – Maximum value in x. If None, use minimum data value.
  • ymin – Minimum value in y. If None, use minimum data value.
  • ymax – Maximum value in y. If None, use minimum data value.
  • Nx – Number of subdivisions in x for contour plot. (Default 100.)
  • Ny – Number of subdivisions in y for contour plot. (Default 100.)
  • cmap – See pp.contour().
  • colors – See pp.contour().
plotutils.plotutils.plot_histogram_posterior(pts, xmin=None, xmax=None, log=False, **args)[source]

Plots a histogram estimate of the posterior from which pts are drawn. Extra arguments are passed to pp.hist().

Parameters:
  • pts – Shape (Npts,) array of samples.
  • xmin – Minimum x value. If None, will be derived from pts.
  • xmax – Maximum x value. If None, will be derived from pts.
  • fmt – Line format; see pp.plot().
  • log – If True compute and plot histogram in log-space.
plotutils.plotutils.plot_histogram_posterior_2d(pts, log=False, cmap=None)[source]

Plots a 2D histogram density of the given points.

Parameters:
  • pts – An (Npts, 2) array of points.
  • log – If True, then compute and plot the histogram in log-space.
  • cmap – Passed to pp.imshow() as colormap.
plotutils.plotutils.plot_interval(pts, levels, *args, **kwargs)[source]

Plot probability intervals corresponding to levels in 1D. Additional args are passed to pp.axvline(). The chosen levels are symmetric, in that they have equal probability mass outside the interval on each side.

Parameters:
  • pts – Shape (Npts,) array of samples.
  • levels – Sequence of levels to plot.
plotutils.plotutils.plot_kde_posterior(pts, xmin=None, xmax=None, N=100, periodic=False, low=None, high=None, log=False, *args, **kwargs)[source]

Plots the a KDE estimate of the posterior from which pts are drawn. Extra arguments are passed to pp.plot().

Parameters:
  • pts – Shape (Npts,) array of samples.
  • xmin – Minimum x value. If None, will be derived from pts.
  • xmax – Maximum x value. If None, will be derived from pts.
  • N – Number of intervals across (xmin, xmax) in plot.
  • periodic – If true, then the function is periodic on the interval.
  • low – If not None, indicates a lower boundary for the domain of the PDF.
  • high – If not None, indicates an upper boundary for the domain of the PDF.
  • log – If True, plot a PDF for log(pts) instead of pts.
Returns:

(xs, ys), the coordinates of the plotted line.

plotutils.plotutils.plot_kde_posterior_2d(pts, xmin=None, xmax=None, ymin=None, ymax=None, Nx=100, Ny=100, cmap=None, log=False, logspace=False)[source]

Plot a 2D KDE estimated posterior.

Parameters:
  • pts – A (Npts, 2) array of points.
  • xmin – Minimum x-coordinate. If None, use the minimum value from pts.
  • xmax – Maximum x-coordinate. If None, use the maximum value from pts.
  • ymin – Minimum y-coordinate. If None, use the minimum value from pts.
  • ymax – Maximum y-coordinate. If None, use the maximum value from pts.
  • Nx – The number of pixels in the x direction.
  • Ny – The number of pixels in the y direction.
  • cmap – The colormap, passed to pp.imshow().
  • log – If True compute and plot the density in log-space.
plotutils.plotutils.plot_kombine_chains(chain, truths=None, mean=True, fburnin=0)[source]

Like plot_emcee_chains() but for kombine.

plotutils.plotutils.plot_kombine_chains_one_fig(chain, fburnin=None)[source]

Like plot_emcee_chains_one_fig() but for kombine.

autocorr Module

Module containing functions to compute the autocorrelation function and estimate the associated autocorrelation length of series.

The estimate of the autocorrelation function is based on the method described at http://www.math.nyu.edu/faculty/goodman/software/acor/ and implemented in the associated acor C++ code, though the implementation details differ.

plotutils.autocorr.autocorrelation_function(series, axis=0)[source]

Returns the autocorrelation function of the given series. The function is normalised so that it is 1 at zero lag.

If series is an N-dimensional array, the ACF will be computed along axis and the result will have the same shape as series.

plotutils.autocorr.autocorrelation_length_estimate(series, acf=None, M=5, axis=0)[source]

Returns an estimate of the autocorrelation length of the given series:

\[L = \int_{-\infty}^\infty \rho(t) dt\]

The estimate is the smallest \(L\) such that

\[L = \rho(0) + 2 \sum_{j = 1}^{M L} \rho(j)\]

In words: the ACL is estimated over a window that is at least \(M\) ACLs long, with the constraint that \(ML < N/2\).

Defined in this way, the ACL gives the reduction factor between the number of samples and the “effective” number of samples. In particular, the variance of the estimated mean of the series is given by

\[\left\langle \left( \frac{1}{N} \sum_{i=0}^{N-1} x_i - \mu \right)^2 \right\rangle = \frac{\left\langle \left(x_i - \mu\right)^2 \right\rangle}{N/L}\]

Returns nan if there is no such estimate possible (because the series is too short to fit \(2M\) ACLs).

For an N-dimensional array, returns an array of ACLs of the same shape as series, but with the dimension along axis removed.

plotutils.autocorr.emcee_chain_autocorrelation_lengths(chain, M=5, fburnin=None)[source]

Returns an array giving the ACL for each parameter in the given emcee chain.

Parameters:
  • chain – The emcee sampler chain.
  • M – See autocorrelation_length_estimate()
  • fburnin – Discard the first fburnin fraction of the samples as burn-in before computing the ACLs. Default is to discard the first \(1/(M+1)\), ensuring that at least one ACL is discarded.
plotutils.autocorr.emcee_gelman_rubin_r(chain, fburnin=None)[source]

Returns the Gelman-Rubin R convergence statistic applied to individual walkers’ trajectories in each parameter.

plotutils.autocorr.emcee_ptchain_autocorrelation_lengths(ptchain, M=5, fburnin=None)[source]

Returns an array of shape (Ntemp, Nparams) giving the estimated autocorrelation lengths for each parameter across each temperature of the parallel-tempered set of chains. If a particular ACL cannot be estimated, that element of the array will be None. See emcee_chain_autocorrelation_lengths() for a description of the optional arguments.

plotutils.autocorr.emcee_thinned_chain(chain, M=5, fburnin=None)[source]

Returns a thinned, burned-in version of the emcee chain.

Parameters:
  • chain – The emcee sampler chain.
  • M – See autocorrelation_length_estimate()
  • fburnin – Discard the first fburnin fraction of the samples as burn-in before computing the ACLs. Default is to discard the first \(1/(M+1)\), ensuring that at least one ACL is discarded.
plotutils.autocorr.emcee_thinned_ptchain(ptchain, M=5, fburnin=None)[source]

Returns a thinned, burned in version of the emcee parallel-tempered chains in ptchain, or None if it is not possible to estimate an ACL for some component of the chain.

plotutils.autocorr.kombine_chain_autocorrelation_lengths(chain, M=5, fburnin=None)[source]

Just like emcee_chain_autocorrelation_lengths() but for kombine.

plotutils.autocorr.plot_emcee_chain_autocorrelation_functions(chain, fburnin=None)[source]

Plots a grid of the autocorrelation function (post burnin) for each of the parameters in the given chain.

plotutils.autocorr.waic(lnlikes, fburnin=None)[source]

Returns an estimate of the WAIC from an emcee sampler’s lnlike (should be of shape (nwalkers, nsteps)). The WAIC is defined by

\[\mathrm{WAIC} = -2 \left( \left\langle \ln \mathcal{L} \right\rangle - \mathrm{Var}\, \ln\mathcal{L} \right).\]

See Gelman, Hwang, and Vehtari (2013) for a motivation for this quantity in terms of an unbiased estimate of the expected log pointwise predictive density.

runner Module

class plotutils.runner.EnsembleSamplerRunner(sampler, pts)[source]

Bases: object

Runner object for an emcee sampler.

acls[source]

Return the estimate of the current chain’s autocorrelation lengths, using plotutils.autocorr.emcee_chain_autocorrelation_lengths().

burnedin_chain[source]

Returns a chain with the first 1/6 of the samples removed. This chain corresponds to the samples that are then thinned to produce the thin_chain property. There is, of course, no guarantee that this chain is actually burned in.

chain[source]

The current state of the sampler’s chain.

lnprobability[source]

The current state of the sampler’s lnprobability.

load_state(dir)[source]

Load a stored state from the given directory.

reset(pts=None)[source]

Resets the stored sampler and internal state. If no pts argument is given, will use the last position of the sampler as the new starting position; otherwise, the new starting position will be given by pts.

rethin()[source]

Increase the thinning parameter by a factor of two, modifying the stored chain and lnprob states accordingly.

run_mcmc(nthinsteps, *args, **kwargs)[source]

Run the associated sampler to produce nthinsteps worth of stored ensembles (i.e. the sampler will be run for nthinsteps*self.thin total steps).

run_to_neff(neff, savedir=None, *args, **kwargs)[source]

Run the sampler, thinning as necessary, until neff effective ensembles are obtained. When savedir is not None, the sampler will be periodically saved to the given directory.

save_state(dir)[source]

Save the state of the runner stored chain, lnprob, and thin parameter in the given directory. Three files will be created (approximately atomically, so the operation is nearly safe from interruption):

  • chain.npy.bz2
  • lnprob.npy.bz2
  • thin.txt

Storing the current chain, lnprob and the thin parameter.

In addition, the file runner.pkl.bz2 will be created storing a pickled version of the runner object.

thin_chain[source]

Return a thinned chain (if possible), using ac.emcee_thinned_chain()

thin_flatchain[source]

Returns a thinned chain that has been flattened.

class plotutils.runner.PTSamplerRunner(sampler, pts)[source]

Bases: plotutils.runner.EnsembleSamplerRunner

Runner class for the PTSampler; basically behaves as EnsembleSamplerRunner, but tailored to the different chain shape and behaviour of emcee.PTSampler.

acls[source]

Return the estimate of the current chain’s autocorrelation lengths, using plotutils.autocorr.emcee_ptchain_autocorrelation_lengths().

burnedin_chain[source]

Returns a chain with the first 1/6 of the samples removed. This chain corresponds to the samples that are then thinned to produce the thin_chain property. There is, of course, no guarantee that this chain is actually burned in.

lnlikelihood[source]

Returns the current state of the sampler’s lnlikelihood.

load_state(dir)[source]

Load a stored state from the given directory.

rethin()[source]

Increase the thinning parameter by a factor of two, modifying the stored chain and lnprob states accordingly.

run_to_neff(neff, savedir=None, *args, **kwargs)[source]

Run the sampler, thinning as necessary, until neff effective ensembles are obtained. When savedir is not None, the sampler will be periodically saved to the given directory.

save_state(dir)[source]

Save the state of the runner stored chain, lnprob, lnlike, betas, and thin parameter in the given directory. Three files will be created (approximately atomically, so the operation is nearly safe from interruption):

  • chain.npy.bz2
  • lnprob.npy.bz2
  • lnlike.npy.bz2
  • beta_history.npy.bz2
  • nswap.txt
  • nswap_accepted.txt
  • nprop.txt
  • nprop_accepted.txt
  • betas.txt
  • time.txt
  • thin.txt

Storing the current chain, lnprob, lnlike, betas (inverse temperatures), and the thin parameter.

In addition, the file runner.pkl.bz2 will be created storing a pickled version of the runner object.

thin_chain[source]

Return a thinned chain (if possible), using ac.emcee_thinned_ptchain()

thin_flatchain[source]

Returns a thinned chain that has been flattened.

plotutils.runner.load_runner(dir)[source]

Loads the saved runner from the given directory.

parameterizations Module

Useful parameterizations for various commonly-found elements of models.

plotutils.parameterizations.bounded_log_jacobian(p, low=-inf, high=inf)[source]

Returns the log of the Jacobian factor

\[\left| \frac{\partial x}{\partial p} \right|\]

for the bounded parameters p.

plotutils.parameterizations.bounded_params(x, low=-inf, high=inf)[source]

Returns the parameters associated with the values x that are bounded between low and high.

plotutils.parameterizations.bounded_values(p, low=-inf, high=inf)[source]

Returns the values, each bounded between low and high (one of these can be None) associated with the parameters p.

The parameterisation is

\[p = \log\left( x - \mathrm{low} \right) - \log\left( \mathrm{high} - x \right)\]

if both lower and upper limits are given, and

\[p = \log\left( x - \mathrm{low} \right)\]

or

\[p = -\log\left( \mathrm{high} - x \right)\]

if only one limit is given.

Parameters:
  • p – The parameters associated with the values. \(-\infty < p < \infty\)
  • low – The lower bound on the parameters. Can be a vector that matches the shape of p.
  • high – The upper bound on the parameters. Can be a vector that matches the shape of p.
plotutils.parameterizations.cov_log_jacobian(x)[source]

Returns the log of the determinant of the Jacobian of the transformation that produces the covariance matrix from parameters x:

\[\log |J| = \log \left| \frac{\partial \Sigma}{\partial x} \right|\]
plotutils.parameterizations.cov_matrix(x)[source]

Returns a covariance matrix from the parameters x, which should be of shape ((N+1)*N/2,) for an (N,N) covariance matrix.

The parametersation is taken from the Stan sampler, and is as follows. The parameters x are the lower-triangluar elements of a matrix, \(y\). Let

\[\begin{split}z_{ij} = \begin{cases} \exp\left(y_{ij}\right) & i = j \\ y_{ij} & \mathrm{otherwise} \end{cases}\end{split}\]

Then the covariance matrix is

\[\Sigma = z z^T\]

With this parameterization, there are no constraints on the components of x.

plotutils.parameterizations.cov_parameters(m)[source]

Given a covariance matrix, m, returns the parameters associated with it through the cov_matrix() function.

plotutils.parameterizations.increasing_log_jacobian(p)[source]

Returns the log of the Jacobian factor

\[\left| \frac{\partial x}{\partial p} \right|\]

for the parameters p.

plotutils.parameterizations.increasing_params(x)[source]

Returns the parameters associated with the values x which should be increasing.

plotutils.parameterizations.increasing_values(p)[source]

Returns the values for parameters p which are constrained to be always increasing.

The parameterisation is

\[\begin{split}p_i = \begin{cases} x_0 & i = 0 \\ \log\left( x_i - x_{i-1} \right) & \mathrm{otherwise} \end{cases}\end{split}\]

Note that \(-\infty < p < \infty\).

plotutils.parameterizations.stable_polynomial_log_jacobian(p, rmin, rmax)[source]
plotutils.parameterizations.stable_polynomial_params(r, rmin, rmax)[source]
plotutils.parameterizations.stable_polynomial_roots(p, rmin, rmax)[source]

A parameterisation of the roots of a real, ‘stable’ polynomial.

A stable polynomial has roots with a negative real part; it is the characteristic polynomial for a linear ODE with decaying solutions. The parameterisation provides a mapping from \(\mathbb{R}^n\) to the roots that is one-to-one; there are no root-permutation degeneracies. The log-Jacobian function produces a flat distribution on the real and imaginary (if any) parts of the roots.

Parameters:
  • p – The array giving the parameters in \(\mathbb{R}^n\) for the roots of the polynomial.
  • rmin – The real part of all the roots is bounded below \(-r_\mathrm{min}\).
  • rmax – The real part of all the roots is bounded above \(-r_\mathrm{max}\), and the imaginary parts of all the roots are bounded between \(-r_\mathrm{max}\) and \(r_\mathrm{max}\).

The parameterisation uses a ‘bounded logit’ transformation to map ranges of reals to \(\pm \infty\):

\[\mathrm{logit}\left(x; a, b\right) = \log(x-a) - log(b-x)\]

The mapping of the roots proceeds as follows. First, discard the roots with strictly negative imaginary parts (these are the conjugates of corresponding roots with strictly positive imaginary parts, so we lose no information). Then, sort the remaining roots in order of decreasing imaginary part; if there are any strictly real roots, with imaginary part zero, sort these in decreasing order, from least negative to most negative.

Let \(a = -\left( r_\mathrm{max} - r_\mathrm{min} \right)\) and \(b = r_\mathrm{max}\). Then, proceeding by pairs of roots:

  • If the imaginary part of root i is greater than zero, then

    \[\begin{split}p_i = \mathrm{logit}\left(\mathrm{im}\left(r_i\right); a, b\right) \\ p_{i+1} = \mathrm{logit}\left(\mathrm{re}\left(r_i\right); -r_\mathrm{max}, -r_\mathrm{min} \right) \end{split}\]

    Then set \(b = \mathrm{im} r_i\), and proceed to the next pair.

  • If the imaginary part of root i is zero, then

    \[\begin{split}p_i = \mathrm{logit}\left( r_i + r_\mathrm{min}; a, b \right) \\ p_{i+1} = \mathrm{logit}\left( r_{i+1} + r_\mathrm{min}; a, r_i + r_\mathrm{min} \right)\end{split}\]

    then set \(b = r_{i+1} + r_\mathrm{min}\).

  • If the number of roots is odd, then the final root must be real, and is the smallest of all the real roots:

    \[p_{N-1} = \mathrm{logit}\left( r_{N-1} + r_\mathrm{min}; a, \mathrm{min}(b, 0) \right).\]

Intuitively, you can imagine constructing the parameterisation using a line that sweeps down the imaginary axis, starting from \(i r_\mathrm{max}\); as it hits each complex root, it records the logit of that root’s imaginary and real parts (which must lie within certain bounds), and then sets the maximum bound for the imaginary part of the next root. Once all the complex roots have been parameterised, a line begins at \(-r_\mathrm{min}\) on the real axis and sweeps left; as it hits each real root, it records the logit of that root between the current bounds, and resets the bound on the maximum value of the next root to the current real root.

The reverse transformation begins by unpacking the first parameter value using the inverse logit transform; if this value is positive, then the root is complex, and the next parameter correponds to the real part. If the value is negative, then this a real root, and the following roots are also real (and negative). Bounds on the subsequent root values are set accordingly in either case for the next inverse logit transformation.

The parameterisation maps the allowed, sorted root space onto the entire \(\mathbb{R}^N\) real space in a one-to-one way.

plotutils.parameterizations.usimp_lengths(p)[source]

Given N-1 parameters, p, returns N positive values that sum to one. The transformation comes from the Stan manual. Imagine a stick that begins with unit length; the parameters are logit-transformed fractions of the amount of the stick remaining that is broken off in each of N-1 steps to produce the N lengths.

plotutils.parameterizations.usimp_log_jacobian(p)[source]

Returns the log of the Jacobian factor,

\[\left| \frac{\partial x}{\partial p} \right|\]

where \(x\) are the unit simplex lengths.

plotutils.parameterizations.usimp_parameters(x)[source]

Returns the N-1 unit simplex parameters that will produce the N lengths x.

bounded_kde Module

class plotutils.bounded_kde.Bounded_kde(pts, low=None, high=None, *args, **kwargs)[source]

Bases: scipy.stats.kde.gaussian_kde

Represents a one-dimensional Gaussian kernel density estimator for a probability distribution function that exists on a bounded domain.

evaluate(xs)[source]

Return an estimate of the density evaluated at the given points.

high[source]

The upper bound of the domain.

low[source]

The lower bound of the domain.

log_kde Module

class plotutils.log_kde.Log_kde(pts, *args, **kwargs)[source]

Represents a one-dimensional Gaussian kernel density estimator conducted in log-space, according to the formula

\[\frac{dN}{d\ln x}(\ln x) = x \frac{dN}{dx}(x)\]

The KDE occurs on the left-hand-side, but the reported distribution is \(dN/dx(x)\).

evaluate(xs)[source]

Returns an estimate of the density at the given points.

contour Module

class plotutils.contour.Contour(data, contours)[source]

A contour calculator. Takes as input a set of points drawn from some distribution, and a set of credible levels. Then Contour.in_contours() computes for any set of points which ones like within the given credible contours and which are outside.

contour_limits[source]

Returns the lower bound on the posterior estimate for inclusion in each of the contours.

contours[source]

Returns the quantiles of the contours represented by this object.

in_contours(pts)[source]

Returns arrays indicating whether the given points are within each of the contours of the object.

Parameters:pts – A (Npts, Ndim) array of points to test against each contour.
Returns:A sequence of the same shape as Contours.contours containing boolean arrays indicating which points lie within the contour.
kde[source]

A Gaussian kernel density estimator for the stored data set.