API Documentation#

Statistics of list of (x, y) pairs from calculator-style summation registers.

source code#

Statistics of list of (x, y) pairs from calculator-style summation registers.

  • mean, standard deviation, max, min of x & y

  • linear regression & correlation coefficient

  • peak analysis: centroid and width of x weighted by y

SummationRegisters()

Summation registers in the style of a pocket calculator.

References:

class pysumreg.sum_registers.SummationRegisters[source]#

Summation registers in the style of a pocket calculator.

Operations

clear()

Clear the \(\sum{}\) summation registers.

add(x, y)

\(\sum{+}\): Add \((x, y)\) ordered pair to the registers.

subtract(x, y)

\(\sum{-}\): Subtract \((x, y)\) ordered pair from the registers.

to_dict([use_registers])

Return all statistics as dictionary.

Statistical Parameters

mean_x

Average of \(x\) values.

mean_y

Average of \(y\) values.

stddev_x

Standard deviation of \(x\) values.

stddev_y

Standard deviation of \(y\) values.

Linear Parameters

slope

First order term (\(b_1\)) in linear fit of \((x,y)\).

intercept

Zero order term (\(b_0\)) in linear fit of \((x,y)\).

correlation

Regression correlation coefficient (\(r\)) of \((x, y)\).

linear_y(x)

Compute \(\hat{y}\) given \(x\) using slope and intercept.

Peak Parameters

centroid

Centroid (\(x_c\)) of \((x, y)\).

sigma

The y-weighted variance (\(\sigma_c^2\)) of \((x, y)\).

add(x, y)[source]#

\(\sum{+}\): Add \((x, y)\) ordered pair to the registers.

property centroid#

Centroid (\(x_c\)) of \((x, y)\).

\[x_c = { \sum{x y} \over \sum{y} }\]

Regardless of the input \((x, y)\) signal modality (single peak, multiple peaks, no peaks at all), it is possible to estimate the center (centroid, \(x_c\)) and width (\(2\sigma\)) of the \(x\) values assuming the \(y\) values are their associated weights. The center should fall between the minimum and maximum given \(x\) values.

See: sigma()

clear()[source]#

Clear the \(\sum{}\) summation registers.

property correlation#

Regression correlation coefficient (\(r\)) of \((x, y)\).

\[r = {{n\sum{xy} - \sum{x}\sum{y}} \over \sqrt{(n\sum{x^2}-\sum{x}\sum{x}) (n\sum{y^2}-\sum{y}\sum{y})}}\]
property intercept#

Zero order term (\(b_0\)) in linear fit of \((x,y)\).

\[y = b_0 + b_1 x\]
\[b_0 = {{\sum{y} - b_1\sum{x}} \over n}\]

See: slope(), linear_y()

linear_y(x)[source]#

Compute \(\hat{y}\) given \(x\) using slope and intercept.

\[\hat{y} = b_0 + b_1 x\]

See: intercept(), slope()

property mean_x#

Average of \(x\) values.

\[\bar{x} = {\sum{x} \over n}\]
property mean_y#

Average of \(y\) values.

\[\bar{y} = {\sum{y} \over n}\]
property sigma#

The y-weighted variance (\(\sigma_c^2\)) of \((x, y)\).

\[\sigma_c^2 = {\sum{y{(x-x_c)}^2} \over \sum{y}}\]

Regardless of the input \((x, y)\) signal modality (single peak, multiple peaks, no peaks at all), it is possible to estimate the center (centroid, \(x_c\)) and width (\(2\sigma_c\)) of the \(x\) values assuming the \(y\) values are their associated weights. The sigma should be less than the span of the \(x\) values.

See: centroid()

property slope#

First order term (\(b_1\)) in linear fit of \((x,y)\).

\[y = b_0 + b_1 x\]
\[b_1 = {{n\sum{xy} - \sum{x}\sum{y}} \over {n\sum{x^2} - \sum{x}\sum{x}}}\]

See: intercept(), linear_y()

property stddev_x#

Standard deviation of \(x\) values.

\[\sigma_x^2 = {{\sum{x^2} - \bar{x}\sum{x}} \over {n-1}}\]
property stddev_y#

Standard deviation of \(y\) values.

\[\sigma_y^2 = {{\sum{y^2} - \bar{y}\sum{y}} \over {n-1}}\]
subtract(x, y)[source]#

\(\sum{-}\): Subtract \((x, y)\) ordered pair from the registers.

to_dict(use_registers=False)[source]#

Return all statistics as dictionary.

Returns None for any unavailable or undefined values.

PARAMETERS

use_registers bool:

Include values of the summation registers. (default: False)