euromod.eu_euromod.calibrate.weighted ===================================== .. py:module:: euromod.eu_euromod.calibrate.weighted .. autoapi-nested-parse:: Weighted statistics on arrays: mean, percentile and Gini coefficient. Every function takes plain arrays of values and survey weights (``dwt`` in EUROMOD output) and returns a number. Below are listed the main public classes of the euromod.eu_euromod.calibrate.weighted module. .. list-table:: **Function** :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`gini `\ (values, weights) - Weighted Gini coefficient, from the area under the Lorenz curve (trapezoids). * - :py:obj:`weighted_mean `\ (values, weights) - Weighted mean. * - :py:obj:`weighted_percentile `\ (values, weights, percentile) - Weighted percentile: the smallest value whose cumulative weight reaches the Functions --------- .. py:function:: gini(values, weights) Weighted Gini coefficient, from the area under the Lorenz curve (trapezoids). :param values: Values (e.g. household income) and their weights, of equal length. Observations where either is missing are left out. :type values: array-like :param weights: Values (e.g. household income) and their weights, of equal length. Observations where either is missing are left out. :type weights: array-like :returns: 0 when everyone has the same value, approaching 1 as it concentrates. :rtype: float .. py:function:: weighted_mean(values, weights) Weighted mean. :param values: Values and their weights, of equal length. :type values: array-like :param weights: Values and their weights, of equal length. :type weights: array-like :rtype: float .. py:function:: weighted_percentile(values, weights, percentile) Weighted percentile: the smallest value whose cumulative weight reaches the requested share of the total weight. The result is always one of ``values``; nothing is interpolated. :param values: Values and their weights, of equal length. :type values: array-like :param weights: Values and their weights, of equal length. :type weights: array-like :param percentile: Between 0 and 100. :type percentile: float :rtype: float