Struct cmb_wtdsummary

Struct Documentation

struct cmb_wtdsummary

A weighted data summary maintaining running tally statistics, derived from the cmb_datasummary parent class.

Public Functions

struct cmb_wtdsummary *cmb_wtdsummary_create(void)

Allocate a weighted data summary object on the heap.

Note that this does not allocate from a thread local memory pool, since it may be passed back outside the current replication.

Returns:

A pointer to a newly allocated weighted data summary object.

void cmb_wtdsummary_initialize(struct cmb_wtdsummary *wsp)

Initialize a weighted data summary, not necessarily allocated on the heap.

Parameters:
  • wsp – Pointer to a weighted data summary.

void cmb_wtdsummary_reset(struct cmb_wtdsummary *wsp)

Reset a previously used weighted data summary to a newly initialized state.

Parameters:
  • wsp – Pointer to a weighted data summary.

void cmb_wtdsummary_terminate(struct cmb_wtdsummary *wsp)

Un-initialize the weighted data summary, returning it to a newly created state.

Parameters:
  • wsp – Pointer to a weighted data summary.

void cmb_wtdsummary_destroy(struct cmb_wtdsummary *wsp)

Deallocate (free) the allocated memory for a weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary previously created by cmb_datasummary_create.

uint64_t cmb_wtdsummary_add(struct cmb_wtdsummary *wsp, double x, double w)

Add a sample (x, w) to the weighted summary. Any zero-weight samples are ignored, not even counted.

Parameters:
  • wsp – Pointer to a weighted data summary.

  • x – Sample value to be added.

  • w – Sample weight to be added.

Returns:

The updated sample count.

uint64_t cmb_wtdsummary_merge(struct cmb_wtdsummary *tgt, const struct cmb_wtdsummary *ws1, const struct cmb_wtdsummary *ws2)

Merge two weighted data summaries. The target may be one of the sources.

See: Pébay & al, “Numerically stable, scalable formulas for parallel and

online computation of higher-order multivariate central moments with

arbitrary weights”, Computational Statistics (2016) 31:1305–1325

Parameters:
  • tgt – Pointer to a weighted summary to receive the merge. Any previous content will be overwritten. Possibly equal to ws1or ws2, or a separate third weighted data summary.

  • ws1 – Pointer to a weighted data summary to be merged.

  • ws2 – Pointer to a weighted data summary to be merged.

Returns:

The combined sample count.

void cmb_wtdsummary_print(const struct cmb_wtdsummary *wsp, FILE *fp, bool lead_ins)

Print a line of basic statistics for the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

  • fp – A file pointer for where to print, possibly stdout

  • lead_ins – Flag to control if explanatory text is printed. If false, only prints a tab-separated line of numeric values.

Public Members

struct cmb_datasummary ds

Parent class, inheriting all properties from there

double wsum

Summed weights

Public Static Functions

static inline uint64_t cmb_wtdsummary_count(const struct cmb_wtdsummary *wsp)

The number of samples in the data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

Returns:

The number of samples in the weighted data summary.

static inline double cmb_wtdsummary_max(const struct cmb_wtdsummary *wsp)

The largest sample value (x) in the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

Returns:

The largest sample value in the data summary.

static inline double cmb_wtdsummary_min(const struct cmb_wtdsummary *wsp)

The smallest sample value (x) in the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

Returns:

The smallest sample value in the data summary.

static inline double cmb_wtdsummary_mean(const struct cmb_wtdsummary *wsp)

The weighted mean of the samples in the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

Returns:

The weighted mean of the samples in the weighted data summary.

static inline double cmb_wtdsummary_variance(const struct cmb_wtdsummary *wsp)

The weighted sample variance of the samples in the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

Returns:

The weighted sample variance of the samples in the weighted data summary.

static inline double cmb_wtdsummary_stddev(const struct cmb_wtdsummary *wsp)

The weighted sample standard deviation of the samples in the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary.

Returns:

The weighted sample standard deviation of the samples in the weighted data summary.

static inline double cmb_wtdsummary_skewness(const struct cmb_wtdsummary *wsp)

The weighted sample skewness of the samples in the weighted data summary.

Parameters:
  • wsp – Pointer to a data summary.

Returns:

The weighted sample skewness of the samples in the weighted data summary.

static inline double cmb_wtdsummary_kurtosis(const struct cmb_wtdsummary *wsp)

The weighted sample excess kurtosis of the samples in the weighted data summary.

Parameters:
  • wsp – Pointer to a weighted data summary

Returns:

The weighted sample excess kurtosis of the samples in the weighted data summary.