Class

NumCosmoMathStatsDist1d

Description [src]

abstract class NumCosmoMath.StatsDist1d : GObject.Object
{
  /* No available fields */
}

Base class for one-dimensional probability distributions on $[x_i, x_f]$.

A subclass provides the density $p(x)$, which need not be normalized, and $-2\ln p(x)$. With NcmStatsDist1d:compute-cdf, ncm_stats_dist1d_prepare() integrates the cumulative distribution as an ODE to NcmStatsDist1d:reltol, in at least 1000 steps, and in units of $p(x_\mathrm{mode})\,(x_f - x_i)$, so its accuracy depends neither on the scale of $p$ nor on that of $x$. The inverse is a Steffen spline through the same knots with $x$ and the probability swapped; it is monotone and stays in $[x_i, x_f]$. Setting $x_i = x_f$ gives a point mass at $x_i$. The mode search uses an internal minimizer, so one object must not be used from several threads at once.

Ancestors

Functions

ncm_stats_dist1d_clear

Decreases the reference count of sd1 and sets the pointer sd1 to NULL.

Instance methods

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.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 NumCosmoMathStatsDist1dClass {
  gdouble (* p) (
    NcmStatsDist1d* sd1,
    gdouble x
  );
  gdouble (* m2lnp) (
    NcmStatsDist1d* sd1,
    gdouble x
  );
  void (* prepare) (
    NcmStatsDist1d* sd1
  );
  gdouble (* get_current_h) (
    NcmStatsDist1d* sd1
  );
  
}

No description available.

Class members
p: gdouble (* p) ( NcmStatsDist1d* sd1, gdouble x )

No description available.

m2lnp: gdouble (* m2lnp) ( NcmStatsDist1d* sd1, gdouble x )

No description available.

prepare: void (* prepare) ( NcmStatsDist1d* sd1 )

No description available.

get_current_h: gdouble (* get_current_h) ( NcmStatsDist1d* sd1 )

No description available.

Virtual methods

NumCosmoMath.StatsDist1dClass.get_current_h

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

NumCosmoMath.StatsDist1dClass.m2lnp
No description available.

NumCosmoMath.StatsDist1dClass.p
No description available.

NumCosmoMath.StatsDist1dClass.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.