Template Class ConditionalDensity

Nested Relationships

Nested Types

Class Documentation

template<typename AuxType = void>
class ConditionalDensity

A kernel density estimate conditioned on some dimensions’ values, owning its points.

Made by KernelDensity::conditional(), or by KernelDensity::marginalize() (a conditional on no dimensions, whose marginal() is 1). Holds the estimate’s points (shifted, reweighted, and pruned copies of the original ones, or for a marginal, copies of them in the kept dimensions, with their auxiliary data), a KernelDensity over them, and the kernel metric to evaluate it with. The points and the view of them the KernelDensity refers to are held through a pointer, so their addresses survive moving the ConditionalDensity.

Template Parameters:

AuxType – As for KernelDensity

Public Functions

inline auto pdf(const std::vector<double> &y, const double relTol, const double absTol) const -> double

Evaluate the conditional density.

Parameters:
Throws:

As – for KernelDensity::pdf()

Returns:

p(y | x0_F), normalized to unit integral over the kept dimensions

inline auto pdf(const std::vector<std::vector<double>> &y, const double relTol, const double absTol) const -> std::vector<double>

Evaluate the conditional density at each of several points, in parallel.

Parameters:
Throws:

As – for KernelDensity’s batch pdf()

Returns:

The density at each point

inline auto percentile(const std::size_t dim, const double pct, const double relTol, const double absTol) const -> double

A one-dimensional percentile of the conditional density.

Parameters:
Throws:

As – for KernelDensity::percentile()

Returns:

As for KernelDensity::percentile(), evaluated with the conditional kernel metric

inline auto percentile(const std::size_t dim, const std::vector<double> &pct, const double relTol, const double absTol) const -> std::vector<double>

Several one-dimensional percentiles of the conditional density, in parallel.

Parameters:
Throws:

As – for KernelDensity’s batch percentile()

Returns:

One value per percentile

inline auto dims() const -> const std::vector<std::size_t>&

The kept dimensions.

Returns:

Their indices in the original estimate, in order; dimension i of this estimate is dims()[i] there

inline auto marginal() const -> double

Density of the original estimate’s marginal over the fixed dimensions, at x0_F.

Returns:

p(x0_F), estimated from the points kept, so low by at most a fraction massTol; p(x0_F, y) = marginal() pdf(y)

inline auto bandwidth() const -> const Bandwidth&

The kernel metric of the conditional estimate.

Returns:

M’_RR (see KernelDensity::conditional())

inline auto kde() const -> const KernelDensity<AuxType>&

The conditional estimate itself.

Returns:

Its KernelDensity, to be evaluated with bandwidth()

inline auto data() const -> const KernelDensityData<AuxType>&

The conditional estimate’s points.

Returns:

Its points, in tree order, with weights normalized to sum to one