Class

NumCosmoMathStatsDist1dEPDF

Description [src]

final class NumCosmoMath.StatsDist1dEPDF : NumCosmoMath.StatsDist1d
{
  /* No available fields */
}

Kernel density estimate of a one-dimensional distribution from weighted observations.

With observations $x_j$ of weights $w_j$, total weight $W$ and bandwidth $h$, the density is $$ p(x) = \frac{1}{c(x)(W + 1)}\left[\frac{1}{\sqrt{2\pi}h}\sum_j w_j e^{-(x - x_j)^2/(2h^2)} + \frac{1}{x_f - x_i}\right], $$ a Gaussian kernel sum plus a uniform component of weight 1, where $c(x) = [\mathrm{erf}((x - x_i)/(\sqrt{2}h)) + \mathrm{erf}((x_f - x)/(\sqrt{2}h))]/2$ is the fraction of a kernel at $x$ inside the support $[x_i, x_f]$. The support is the range of the observations, or wider when set by ncm_stats_dist1d_epdf_set_min() and ncm_stats_dist1d_epdf_set_max().

Observations closer than $\sigma\,s$, with $\sigma$ their standard deviation and $s$ NcmStatsDist1dEPDF:sd-min-scale, are merged into their weighted mean. Merging happens in ncm_stats_dist1d_prepare() and whenever more than NcmStatsDist1dEPDF:max-obs observations were added since the last merge; the limit then grows to ten times the merged count.

The bandwidth follows NcmStatsDist1dEPDF:bandwidth, see NcmStatsDist1dEPDFBw. The automatic bandwidth is a diffusion (Botev-type) plug-in selector on a $2^{14}$-bin histogram of the merged observations over $[x_i - R/2, x_f + R/2]$, $R = x_f - x_i$, iterated from the rule-of-thumb value. For Gaussian data it is within 20% of the AMISE-optimal bandwidth for $N$ from $10^4$ to $10^6$; on the claw density of Marron and Wand it is five times the optimum at $N = 10^5$. The rule-of-thumb and automatic bandwidths use the number of observations $N$, not their weights, and the interquartile range ignores the weights.

Constructors

ncm_stats_dist1d_epdf_new

Creates a new NcmStatsDist1dEPDF with the automatic bandwidth and the default NcmStatsDist1dEPDF:max-obs.

ncm_stats_dist1d_epdf_new_full

Creates a new NcmStatsDist1dEPDF, see NcmStatsDist1dEPDF:max-obs, NcmStatsDist1dEPDF:bandwidth, NcmStatsDist1dEPDF:h-fixed and NcmStatsDist1dEPDF:sd-min-scale.

Functions

ncm_stats_dist1d_epdf_clear

Decreases the reference count of epdf1d by one and sets epdf1d to NULL.

Instance methods

ncm_stats_dist1d_epdf_add_obs

Adds the observation x with weight 1, see ncm_stats_dist1d_epdf_add_obs_weight().

ncm_stats_dist1d_epdf_add_obs_weight

Adds the observation x with weight w; it enters the estimate at the next ncm_stats_dist1d_prepare(). A zero weight is ignored; a non-finite x or a negative w is skipped with a warning.

ncm_stats_dist1d_epdf_free

Decreases the reference count of epdf1d by one.

ncm_stats_dist1d_epdf_get_bw_type
No description available.

ncm_stats_dist1d_epdf_get_h_fixed
No description available.

ncm_stats_dist1d_epdf_get_obs_mean
No description available.

ncm_stats_dist1d_epdf_ref

Increases the reference count of epdf1d by one.

ncm_stats_dist1d_epdf_reset

Discards all observations and the bounds; ncm_stats_dist1d_prepare() aborts until an observation is added.

ncm_stats_dist1d_epdf_set_bw_type

Sets NcmStatsDist1dEPDF:bandwidth; takes effect at the next ncm_stats_dist1d_prepare().

ncm_stats_dist1d_epdf_set_h_fixed

Sets NcmStatsDist1dEPDF:h-fixed, the bandwidth of #NCM_STATS_DIST1D_EPDF_BW_FIXED; takes effect at the next ncm_stats_dist1d_prepare().

ncm_stats_dist1d_epdf_set_max

Sets the upper bound of the support; a larger observation added later raises it. Takes effect at the next ncm_stats_dist1d_prepare().

ncm_stats_dist1d_epdf_set_min

Sets the lower bound of the support; a smaller observation added later lowers it. Takes effect at the next ncm_stats_dist1d_prepare().

Methods inherited from NcmStatsDist1d (18)
ncm_stats_dist1d_eval_inv_pdf

Evaluates the inverse of the cumulative distribution, the $x$ with $\int_{x_i}^x p(x^\prime)\,\mathrm{d}x^\prime = u$. Returns $x_i$ for $u \leq 0$ and $x_f$ for $u \geq 1$. Requires NcmStatsDist1d:compute-cdf.

ncm_stats_dist1d_eval_inv_pdf_tail

Evaluates the $x$ with $\int_x^{x_f} p(x^\prime)\,\mathrm{d}x^\prime = v$, that is ncm_stats_dist1d_eval_inv_pdf() at $1 - v$, so v below $\epsilon$ is not resolved. Returns $x_f$ for $v \leq 0$ and $x_i$ for $v \geq 1$. Requires NcmStatsDist1d:compute-cdf.

ncm_stats_dist1d_eval_m2lnp

Evaluates $-2\ln p(x)$ of the density as given by the subclass, without the normalization, see ncm_stats_dist1d_eval_norma().

ncm_stats_dist1d_eval_mode

Locates the maximum of the density: the minimum of $-2\ln p$ on 1000 equally spaced points, refined by Brent’s method between the two neighbouring grid points to a relative tolerance $\sqrt{\mathrm{reltol}}$ and an absolute tolerance, the larger of NcmStatsDist1d:abstol and $\sqrt{\mathrm{reltol}}$ times the grid spacing. The absolute tolerance is what stops the refinement of a mode at zero. When the two best grid points tie, Brent’s method refines between them. The grid point is returned when it is $x_i$ or $x_f$, or when a neighbour has zero density. Warns if the refinement stops before its tolerance, or leaves its bracket unchanged for ten iterations.

ncm_stats_dist1d_eval_norma

Gets the integral of the subclass density over $[x_i, x_f]$, computed by ncm_stats_dist1d_prepare(); 1 without NcmStatsDist1d:compute-cdf.

ncm_stats_dist1d_eval_p

Evaluates the density at x divided by the normalization. Without NcmStatsDist1d:compute-cdf the normalization is 1 and the density is not normalized.

ncm_stats_dist1d_eval_pdf

Evaluates the cumulative distribution $\int_{x_i}^x p(x^\prime)\,\mathrm{d}x^\prime$. Requires NcmStatsDist1d:compute-cdf; x is not checked.

ncm_stats_dist1d_free

Decreases the reference count of sd1.

ncm_stats_dist1d_gen

Draws a value from the distribution by inverting the cumulative distribution at a uniform deviate. Requires NcmStatsDist1d:compute-cdf.

ncm_stats_dist1d_get_compute_cdf
No description available.

ncm_stats_dist1d_get_current_h

Gets the kernel bandwidth of a kernel density estimate. Aborts for a subclass that does not implement it.

ncm_stats_dist1d_get_xf
No description available.

ncm_stats_dist1d_get_xi
No description available.

ncm_stats_dist1d_prepare

Calls the subclass prepare and then, when $x_i \neq x_f$ and NcmStatsDist1d:compute-cdf is TRUE, locates the mode, integrates the cumulative distribution and the normalization, and builds the inverse. Must be called after changing $x_i$, $x_f$ or the density. Aborts if $x_f < x_i$ or if the density at the mode is not positive and finite.

ncm_stats_dist1d_ref

Increases the reference count of sd1.

ncm_stats_dist1d_set_compute_cdf

Sets NcmStatsDist1d:compute-cdf. Without it ncm_stats_dist1d_prepare() computes neither the normalization nor the cumulative distribution and its inverse.

ncm_stats_dist1d_set_xf

Sets NcmStatsDist1d:xf.

ncm_stats_dist1d_set_xi

Sets NcmStatsDist1d:xi.

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

NumCosmoMath.StatsDist1dEPDF:bandwidth
No description available.

NumCosmoMath.StatsDist1dEPDF:h-fixed
No description available.

NumCosmoMath.StatsDist1dEPDF:max-obs
No description available.

NumCosmoMath.StatsDist1dEPDF:n-obs
No description available.

NumCosmoMath.StatsDist1dEPDF:sd-min-scale
No description available.

Properties inherited from NcmStatsDist1d (6)
NumCosmoMath.StatsDist1d:abstol
No description available.

NumCosmoMath.StatsDist1d:compute-cdf
No description available.

NumCosmoMath.StatsDist1d:norma
No description available.

NumCosmoMath.StatsDist1d:reltol
No description available.

NumCosmoMath.StatsDist1d:xf
No description available.

NumCosmoMath.StatsDist1d:xi
No description available.

Signals

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct NumCosmoMathStatsDist1dEPDFClass {
  NcmStatsDist1dClass parent_class;
  
}

No description available.

Class members
parent_class: NcmStatsDist1dClass

No description available.