Skip to content

KernelDensity

Weighted Gaussian kernel density of one variable: a smooth reference distribution for NormalScore when the data are too few or too clustered to define the tails.

Parameters:

Name Type Description Default
bandwidth (silverman, scott)

Kernel width: Silverman's rule 0.9 min(sd, IQR / 1.34) n^-1/5 (default), robust to skewed and bimodal data, Scott's rule 1.06 sd n^-1/5, or a width, in log units when log. n is the effective number of samples of the weights.

"silverman"
lower float

Bounds of the values, kept by reflecting the kernels at them, e.g. lower=0 for grades.

required
upper float

Bounds of the values, kept by reflecting the kernels at them, e.g. lower=0 for grades.

required
log bool

Kernels on ln x: positive values with a lognormal-like upper tail.

False

Attributes:

Name Type Description
bandwidth_ float

The fitted kernel width.

cdf method descriptor

cdf(x)

Probability of a value at most each of x.

fit method descriptor

fit(values, *, weights=None, data=None)

Fits the density to values.

Parameters:

Name Type Description Default
values array_like or str

Finite values, or the column of data holding them.

required
weights array_like or str

Declustering weights, or their column.

None
data (PointSet, Table or mapping)

Holds the columns named by the other arguments.

None

from_json staticmethod

from_json(text)

Reads to_json output; raises InvalidInput on another class's JSON or a newer format.

pdf method descriptor

pdf(x)

Density at each of x, zero outside the bounds.

quantile method descriptor

quantile(p)

Value at each cumulative probability of p, in (0, 1).

sample method descriptor

sample(n, *, seed=0)

n values drawn from the density; the same seed gives the same values.

to_json method descriptor

to_json()

JSON of the parameters and, once fitted, the fitted state.

used in