Contents:
Determine the lower and upper confidence levels required to enclose a given fraction ‘frac’ of a KDE object’s dataset(s) to within a tolerance ftol.
Return the confidence level of a 2D histogram or array that encloses the specified fraction of the total sum.
INPUTS: |
|
---|---|
OPTIONS: |
|
Find the “x”-value such that kde(x)=val +/- tol
Without a specified guess for a monomodal distribution, tends to find the lower of the two possible values.
Uses scipy.stats.gaussian_kde objects
Determine the maximum value of a KDE INPUT: scipy.stats.kde object
Generate a 2D histogram map from data, using Gaussian KDEs
INPUTS: |
|
---|---|
OPTIONAL_INPUTS: | |
|
|
RETURNS: | [kdehist, xbins, ybins] |
EXAMPLE: | import kdestats as kde
import numpy as np
import pylab as py
covmat = [[1., 1.5], [1.5, 4.]]
xy = np.random.multivariate_normal([0, 0], covmat, [1e4])
kdehist = kde.kdehist2(xy[:,0], xy[:,1], [30, 30])
clevels = kde.confmap(kdehist[0], [.6827,.9545,.9973])
py.figure() # Plot 1-, 2-, and 3-sigma contours
c = py.contour(kdehist[1], kdehist[2], kdehist[0], clevels)
|