Weighted Statistics

GX-TXT DEV112 P011-bis

Compute weighted statistics and check the contribution of the weights to the result of the example.

Enable the module and prepare the two kinds of weight

In Configuration → Modules → Analysis & Services search for Weighted Statistics (analysis.statistics.weighted) and press Enable module if it is off. Open Analysis and select Run / recalculate now to run the module.

For statistical weights use New Session → Generate Session… and choose Statistics (statistics, 1.0.1) in the public catalog. Keep Standalone Session and give it a unique name. The Dataset statistics.source contains value_V and weight. For absolute uncertainties generate a second Session with Weighted Regression (weighted_regression, 1.0.1). In regression.linear uses y and sigma_y, both in volts. The Weighted Statistics module uses the two bound quantities and does not require an independent X column.

In Dataset → Preview and Open Dataset → Canonical table check content, units, missing rows and zero weights. Keep the two studies separate.

The Statistics Generator prepares a table with non-negative weights and intentional non-finite values.
The Statistics Generator prepares a table with non-negative weights and intentional non-finite values.
The Weighted Regression Generator also prepares absolute standard uncertainties in the units of the measurement.
The Weighted Regression Generator also prepares absolute standard uncertainties in the units of the measurement.

Bind measurement, weights and uncertainties

Control
Dataset sources, Numeric measurement
Choices and conditions
Bind the Dataset to the role primary. Type value_V or y in the numeric field. The mean result uses the unit of the measurement.
Control
Statistical weight or measurement uncertainty
Choices and conditions
Bind weight for statistical weights, or sigma_y for standard uncertainties. The choice must match Weight semantics.
Control
Data selection (optional X interval)
Choices and conditions
None uses all rows. A compatible X selection limits the available pairs. The bindings stay row by row.
Control
Weight semantics
Choices and conditions
statistical_weight the default, interprets non-negative relative weights. A zero weight leaves a finite pair with no contribution. inverse_variance_uncertainty interprets the second variable as a positive σ compatible with the measurement, and computes w = 1/σ².
Control
Mean uncertainty model
Choices and conditions
none the default, leaves the sample standard error not applicable. sampling requests an estimate covered by the sampling assumptions and uses the effective sample size. In the absolute-uncertainty model the known component of the mean is distinct from the sampling contribution.
Control
NaN / Inf policy
Choices and conditions
With omit the default, excludes a non-finite pair. error rejects the computation with a non-finite pair.
Control
Weighted quantile probabilities
Choices and conditions
Probabilities between 0 and 1. Prefilled with 0;0.25;0.5;0.75;1. Each quantile uses the inverse of the weighted empirical distribution. It is the first ordered value whose cumulative weight reaches the threshold.
Control
Output Dataset ID prefix
Choices and conditions
Initially statistics.weighted. Use distinct prefixes, for example weighted.sampling and weighted.incertezza. The module adds .summary and .quantiles.
Configuration of the statistical weights and the sampling model.
Configuration of the statistical weights and the sampling model.
The second variable is sigma_y, used as an absolute uncertainty.
The second variable is sigma_y, used as an absolute uncertainty.

Limit the estimates to a saved interval

To check the effect of the selection, use Grouped Statistics Student Lab with student.grouped.source. Set sample with unit 1 in the editor Dataset → Variables and save. Assign voltage_V as the measurement and sample as a dimensionless weight, with statistical_weight, sampling and omit. Here the index is only used to build teaching weights that differ from each other. Choose sel_001 and use the new prefix ponderate.intervallo. The report gives 16 selected pairs, 15 finite positive pairs, a sum of weights of 157 and a weighted mean of 3.07388535 V.

Run and tell apart the two precision measures

In Run update the plan and press Run enabled analyses. In Results find .summary, .quantiles and the report. In Dataset check Preview, the metadata analysis.statistical_results and Technical Details / Provenance. Open the canonical tables. The module records tables and a report without plots of its own.

In the Dataset statistics.source with omit 11 finite pairs remain. Ten weights are positive and one is zero. The sum of the weights is 15, the weighted mean 2.8 V and the weighted median 2 V. Kish’s effective sample size, (Σw)² / Σw², is 8.3333. The population variance divides the weighted residual by Σw. The sample variant corrects the denominator for reliability weights. With sampling the standard error of the mean is about 1.5148 V. With none the state of that entry is not applicable.

With regression.linear, y, sigma_y and inverse_variance_uncertainty there are 41 finite pairs. The mean is about 14.7360 V. The known standard uncertainty of the mean is about 0.02464 V, equal to 1/√Σw if the uncertainties are absolute, independent and suitable inputs. It is a quantity distinct from the standard error from sampling dispersion. Uncertainties are not interpreted by using an arbitrary numerical weight.

Summary of the statistical weights with counts, mean and precision measures.
Summary of the statistical weights with counts, mean and precision measures.
Summary published for known standard uncertainties in volts.
Summary published for known standard uncertainties in volts.