Skip to content

get_weighted_variance()

get_weighted_variance() computes the weighted variance of a numeric vector.

Function Usage

python
from sequenzo import get_weighted_variance
value = get_weighted_variance(values, weights=None, remove_missing=True, method="unbiased")

Entry Parameters

ParameterRequiredTypeDescription
valuesarray-likeNumeric values to summarize.
weightsarray-like or NoneOptional weights. If None, all values are equally weighted.
remove_missingboolIf True, remove missing values before computing.
methodstrVariance estimation method, default unbiased.

What It Does

  • Validates inputs and aligns values and weights.
  • Optionally removes missing values.
  • Computes weighted variance using the selected method.

Examples

python
from sequenzo import get_weighted_variance

values = [2, 4, 8]
weights = [1, 1, 2]

result = get_weighted_variance(values, weights=weights, method="unbiased")
print(result)

R Counterpart

  • Closest R function: weighted.var
  • Mapping note: Sequenzo marks this as equivalent helper behavior in code and exposes weighted variance with method-based estimation.

Notes

  • This is a general weighted statistics function commonly used in R-style workflows.
  • It is not specific to TraMineR, but is useful in sequence-analysis summaries.

Authors

Code: Yuqi Liang

Documentation: Yuqi Liang