WOLFRAM

WeightedData[{x1,x2,},{w1,w2,}]

represents observations xi with weights wi.

WeightedData[{x1,x2,},fn]

represents observations xi with weighting function fn.

Details

  • WeightedData augments data with weights for each data point.
  • The data {x1,x2,} and weights {w1,w2,} should be lists of equal length.
  • The weight function fn is applied to the list {x1,x2,} and should return an explicit list of weights {w1,w2,}.
  • WeightedData can be used in statistics functions including:
  • Mean,Variance,descriptive statistics functions
    EmpiricalDistribution,nonparametric distribution estimation
    EstimatedDistribution,parametric distribution estimation
  • WeightedData[{x1,x2,}] gives data with equal weights.
  • Properties of WeightedData can be obtained by specifying WeightedData[]["property"].
  • A list of available properties can be obtained using WeightedData[]["Properties"].
  • WeightedData has the following properties:
  • "EmpiricalPDF"data values and estimated weights
    "InputData"unweighted input data values
    "MetaInformation"a list containing meta-information rules
    "Weights"a list containing the data weights

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

Create data with weights:

Out[3]=3

Compute a weighted Mean and StandardDeviation:

Out[4]=4
Out[5]=5

Scope  (10)Survey of the scope of standard use cases

Create weighted univariate data:

Some weighted descriptive statistics:

Out[4]=4

Add weights to a set of multivariate values:

Out[2]=2

A set of weighted multivariate descriptive statistics:

Out[3]=3
Out[4]=4
Out[5]=5

Use a pure function to create weighted data values:

Weighted means and variances:

Out[3]=3
Out[4]=4

Visualize the impact of the various weighting schemes:

Out[5]=5

Fit nonparametric distributions to weighted data:

Out[2]=2
Out[4]=4

Fit parametric distributions to weighted data:

Out[2]=2
Out[3]=3

Compare the estimated and empirical distributions:

Out[5]=5

Extract the input data from a WeightedData object:

Compare the distributions of the unweighted and weighted data:

Out[5]=5

Obtain the weights from a WeightedData object:

Visually inspect the effect of the weights on the data values:

Out[3]=3

Compute a weighted mean from the empirical PDF:

Out[3]=3

The weighted mean can be computed directly using Mean:

Out[4]=4

Find the weighted average of an irregularly sampled TimeSeries:

Out[1]=1
Out[2]=2

Compare with the average of values:

Out[3]=3
Out[4]=4

Create weighted data involving quantities:

Some weighted descriptive statistics:

Applications  (2)Sample problems that can be solved with this function

Create a weighted histogram:

Out[21]=21

Estimate confidence interval for maximum likelihood estimates of distribution parameters:

Out[2]=2

Apply fractional random weight bootstrap to estimate confidence interval, by repeating weighted estimation with weights sampled from a DirichletDistribution with unit parameters:

Generate one thousand estimates of the distribution parameters:

Visualize bootstrap estimates:

Out[6]=6

Fit joint Gaussian distribution to the bootstrapped parameters:

Out[7]=7

Properties & Relations  (2)Properties of the function, and connections to other functions

Descriptive statistics are based on the underlying EmpiricalDistribution:

Out[3]=3

Sample estimates are given when they differ from population estimates:

Out[4]=4

WeightedData works for TimeSeries objects:

Out[1]=1

For , the weights are proportional to :

Out[2]=2
Out[3]=3

Compare with binsampled time average:

Out[4]=4
Out[5]=5

Compute integration limits:

Out[7]=7
Out[8]=8
Wolfram Research (2012), WeightedData, Wolfram Language function, https://reference.wolfram.com/language/ref/WeightedData.html.
Wolfram Research (2012), WeightedData, Wolfram Language function, https://reference.wolfram.com/language/ref/WeightedData.html.

Text

Wolfram Research (2012), WeightedData, Wolfram Language function, https://reference.wolfram.com/language/ref/WeightedData.html.

Wolfram Research (2012), WeightedData, Wolfram Language function, https://reference.wolfram.com/language/ref/WeightedData.html.

CMS

Wolfram Language. 2012. "WeightedData." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WeightedData.html.

Wolfram Language. 2012. "WeightedData." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WeightedData.html.

APA

Wolfram Language. (2012). WeightedData. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WeightedData.html

Wolfram Language. (2012). WeightedData. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WeightedData.html

BibTeX

@misc{reference.wolfram_2025_weighteddata, author="Wolfram Research", title="{WeightedData}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/WeightedData.html}", note=[Accessed: 07-March-2025 ]}

@misc{reference.wolfram_2025_weighteddata, author="Wolfram Research", title="{WeightedData}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/WeightedData.html}", note=[Accessed: 07-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_weighteddata, organization={Wolfram Research}, title={WeightedData}, year={2012}, url={https://reference.wolfram.com/language/ref/WeightedData.html}, note=[Accessed: 07-March-2025 ]}

@online{reference.wolfram_2025_weighteddata, organization={Wolfram Research}, title={WeightedData}, year={2012}, url={https://reference.wolfram.com/language/ref/WeightedData.html}, note=[Accessed: 07-March-2025 ]}