Template Class ConditionalDensity
Defined in File KernelDensity.hpp
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:
y – Position in the kept dimensions (see dims()); elements may be NaN, to marginalize over them too
relTol – As for KernelDensity::pdf()
absTol – As for KernelDensity::pdf()
- 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:
y – The points, each with one element per kept dimension (see dims())
relTol – As for KernelDensity::pdf()
absTol – As for KernelDensity::pdf()
- 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:
dim – Index of the dimension among the kept ones (see dims())
pct – The percentile, in (0, 100)
relTol – As for KernelDensity::percentile()
absTol – As for KernelDensity::percentile()
- 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:
dim – As for the single-percentile version
pct – The percentiles, each in (0, 100)
relTol – As for KernelDensity::percentile()
absTol – As for KernelDensity::percentile()
- 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